This guide will help you publish the Cvians UI component library to npm so everyone can use it.
- npm account - Create an account at npmjs.com
- npm CLI - Ensure npm is installed and you're logged in:
npm login
- GitHub repository - Push your code to GitHub first
The packages will be published under the @cvians scope:
@codvista/cvians-excel-table- Core components@codvista/cvians-cli- CLI installation tool
If @cvians is unavailable, consider:
@your-username/cvians-excel-table@your-org/cvianscvians-ui
The package names are already set correctly:
@codvista/cvians-excel-table@codvista/cvians-cli@cvians/root(private)
pnpm changeset initpnpm changesetSelect packages to release and provide a description.
# Version packages
pnpm changeset version
# Build all packages
pnpm build
# Publish to npm
pnpm changeset publishCreate .github/workflows/release.yml:
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Build Packages
run: pnpm build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}In your GitHub repository settings, add:
NPM_TOKEN- Your npm automation token
Your final package structure:
@codvista/cvians-excel-table/
├── dist/
│ ├── index.js # ESM build
│ ├── index.cjs # CommonJS build
│ └── index.d.ts # TypeScript declarations
├── package.json
└── README.md
@codvista/cvians-cli/
├── dist/
│ ├── cli.js # CLI executable
│ └── index.js # Library exports
├── package.json
└── README.md
After publishing, users can install with:
# Core components
npm install @codvista/cvians-excel-table
# CLI tool (global)
npm install -g @codvista/cvians-cliOr use the CLI:
npx @codvista/cvians-cli init
npx @codvista/cvians-cli add excel-table# Install locally in project
npm install @codvista/cvians-cli
npx cvians init
npx cvians add excel-tableConsider hosting documentation on:
- GitHub Pages - Free static hosting
- Vercel - Easy deployment from GitHub
- Netlify - Alternative static hosting
- Storybook - Component documentation
Use semantic versioning:
0.1.0- Initial release0.1.1- Bug fixes0.2.0- New features1.0.0- Stable API
-
Pack locally:
pnpm --filter @your-username/excel-table-core pack
-
Test in another project:
npm install ./path/to/packed-file.tgz
-
Test CLI:
npm link cvians --help
- All tests pass
- Documentation is complete
- Examples work correctly
- Package names are available on npm (@cvians scope)
- README has installation instructions
- License file is included
- TypeScript declarations are generated
- Both ESM and CommonJS builds work
- CLI tool is executable
- Version numbers are correct
After initial publishing:
- Fix bugs → patch version (0.1.1)
- Add features → minor version (0.2.0)
- Breaking changes → major version (1.0.0)
Always use changesets for version management:
pnpm changeset
pnpm changeset version
pnpm changeset publishAfter publishing:
- Share on social media
- Post on Reddit (r/reactjs, r/webdev)
- Write a blog post
- Submit to awesome lists
- Create demo videos
Your Cvians UI component library is now ready to be shared with the world! 🎉