Studio customization
Structure builder
Was this page helpful?
Publish a plugin for distribution
After developing and testing a plugin, it is time to publish it to npm.
If you use @sanity/plugin-kit for your package, the prepublishOnly script will ensure that the package is validated and builds according to plugin-kit expectations. These checks are in place to prevent an array of common errors from slipping through when publishing.
If you are comfortable with publishing from your local development environment, in your package directory run:
npm run publishpnpm run publishyarn run publishbun run publishThis will build and publish your package to npm. It will ask for a one-time code if you have 2-factor authentication enabled on your npm account (you should).
When you manually publish like this, you are responsible for bumping the version field in package.json manually between releases. You also have to manually tag and create a release on GitHub if you want that sort of thing.
Scoped packages (package name starts with @ ie: @orgOrNpmUser/package) are private by default. This implies:
To make your package public (which will circumvent the above limitations), add the following to your package.json:
"publishConfig": { "access": "public" }
This section uses a @sanity/plugin-kit preset template to do most of the work. It puts certain guardrails on the development process to lower the chance of a faulty publish event. Feel free to make changes to the setup, look to it for inspiration or completely disregard it.
If you want to do automated releases using GitHub Actions, @sanity/plugin-kit has this covered via the injectable semver-workflow preset.
Consider using this preset if you want the following:
That said, all of these can be opted-out of by simply reverting the changes you don’t care for.
Before continuing, ensure that your package has no local changes, so it is easy to check what changes are applied to your code.
In your plugin directory run:
npx @sanity/plugin-kit inject --preset-only --preset semver-workflow && npm i
This command will configure the plugin package with files and dependencies that accommodate an automated plugin workflow on GitHub.
Keep in mind that this setup is tailored to the needs of the Ecosystem team at Sanity. Feel free to modify any and all files injected by the preset, or use it as a basis for creating your own workflow.
For more on this, refer to the semver-workflow preset docs.
npm run publishpnpm run publishyarn run publishbun run publishnpx @sanity/plugin-kit inject --preset-only --preset semver-workflow && npm i