Publish TypeScript SDKs manually
This guide covers publishing TypeScript SDKs manually. For information on automating TypeScript SDK publishing, see Publish TypeScript SDKs automatically.
To share your generated TypeScript SDK with the community, you can publish it to npm. This enables other developers to easily install it using npm. Follow the steps below.
Prerequisites
To publish your SDK to npm, you need the following:
- An npm account. You can create it at npmjs.com.
- npm CLI installed. You can install it with Node.js from nodejs.org.
- A unique package name. You can check availability using the
npm search your-package-namecommand.
Publish your TypeScript SDK to npm
-
Configure
package.json. Ensure these fields are set correctly: -
Build the SDK.
-
Sign in to npm.
-
Publish the package.
-
For public packages, use:
-
For scoped private packages, use:
-
-
Verify publication:
Publish updates
To publish an updated SDK, update the version in the package.json following the semantic versioning:
- Patch:
1.0.0→1.0.1(bug fixes) - Minor:
1.0.0→1.1.0(new features, backward compatible) - Major:
1.0.0→2.0.0(breaking changes)
Alternatively, you can use the npm version command:
Best practices for publishing TypeScript SDKs
Use the following best practices when publishing your TypeScript SDK to npm:
- Use
.npmignoreto exclude unnecessary files. - Include a comprehensive
README.md. - Add a
LICENSEfile. - Tag releases in Git:
git tag v1.0.0 && git push --tags. - Set up CI/CD for automated publishing.
- Consider using
nptool for streamlined publishing:npx np.