This is a React SDK for building UI Apps for Agility CMS.
If you want to develop this SDK locally and test it in another project, follow these steps:
First, clone the repository and install dependencies.
git clone https://github.com/agility/agility-cms-app-sdk.git
cd agility-cms-app-sdk
yarn install
Before using the SDK in your local project, build the package using the following command:
yarn build
This will clean, compile, and bundle the SDK, placing the output in the dist
folder.
To use the SDK in your local project, you can use yarn link. This allows your local project to reference the SDK directly without needing to publish it to npm.
cd agility-cms-app-sdk
yarn link
Once the SDK is linked, you can link it to your project:
cd your-project
yarn link "@agility/app-sdk"
At this point, your project will use the local version of the SDK.
If you're actively developing the SDK, you can start the watch mode for continuous builds:
cd agility-cms-app-sdk
yarn watch
This will watch for changes and rebuild the SDK as needed.
To avoid conflicts between React versions, React is treated as a peer dependency and is not bundled with the SDK. This ensures that your project provides the React version, and you don't need to manually link React.
You may run into issues trying link to apps that are using Next.JS. If you can an error like that you can try to add the following to your next.config.js
:
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
react: path.resolve(__dirname, "node_modules/react"),
"react-dom": path.resolve(__dirname, "node_modules/react-dom")
}
return config
},
- Peer Dependencies: The SDK expects your project to provide its own version of react and react-dom that meets the version requirements specified in the SDK’s peerDependencies.
- Shared React: As long as your project provides a compatible React version, everything will work without requiring manual linking.
This setup prevents version conflicts, avoids the need for linking React manually, and ensures that your project and the SDK share the same React instance.
To unlink the SDK from your project, run the following command:
In your project:
cd your-project
yarn unlink "@agility/app-sdk"
In the SDK:
cd agility-cms-app-sdk
yarn unlink
This will restore the original packages from npm in both your SDK and the project.
One of the best ways to learn a new SDK is to see some examples! Check out these sample apps to help you get started:
A dashboard app that uses OAuth to connect to Google and pull Google Analytics data.
A sidebar app that translates and detects language for the current content item.
A custom field app that allows selection of a product from BigCommerce. It includes a modal with a product listing and search component.