23blocks SDK Development Guide
December 13, 2025 · View on GitHub
Prerequisites
- Node.js >= 18.0.0
- npm >= 10.0.0
Getting Started
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm run test
Project Structure
packages/
├── contracts/ # Core types & interfaces
├── jsonapi-codec/ # JSON:API v1.0 codec
├── transport-http/ # HTTP transport layer
├── block-authentication/ # Authentication block
├── block-search/ # Search block
├── angular/ # Angular bindings (RxJS)
├── react/ # React bindings (hooks)
└── sdk/ # Meta-package
Available Scripts
| Script | Description |
|---|---|
npm run build | Build all packages |
npm run build:affected | Build only affected packages |
npm run test | Run all tests |
npm run test:affected | Test only affected packages |
npm run lint | Lint all packages |
npm run typecheck | Type-check all packages |
npm run clean | Clean all build artifacts |
npm run graph | Visualize dependency graph |
Local Testing (Without Publishing to NPM)
Option 1: yalc (Recommended)
yalc creates a local package registry, simulating a real npm install.
# Install yalc globally (one-time)
npm install -g yalc
# Build and publish to local yalc store
npm run build
npm run yalc:publish
# In your consumer project:
cd /path/to/your/project
# Add packages from yalc
yalc add @23blocks/contracts
yalc add @23blocks/jsonapi-codec
yalc add @23blocks/transport-http
yalc add @23blocks/block-authentication
yalc add @23blocks/react # or @23blocks/angular
# Install dependencies
npm install
# When you make changes to the SDK:
cd /path/to/sdk
npm run build
npm run yalc:push # Updates all linked projects automatically
To remove yalc links:
yalc remove @23blocks/contracts
yalc remove --all # Remove all yalc packages
Option 2: npm link
# In SDK root
npm run build
# Link each package
cd packages/contracts && npm link
cd ../jsonapi-codec && npm link
cd ../transport-http && npm link
cd ../block-authentication && npm link
cd ../react && npm link
# In your consumer project
npm link @23blocks/contracts
npm link @23blocks/jsonapi-codec
npm link @23blocks/transport-http
npm link @23blocks/block-authentication
npm link @23blocks/react
Option 3: Local Verdaccio Registry
# Start local registry (runs on http://localhost:4873)
npm run local-registry
# In another terminal, publish to local registry
npm config set registry http://localhost:4873
npm run build
npx nx release publish --registry http://localhost:4873
# In your consumer project
npm config set registry http://localhost:4873
npm install @23blocks/react
# Reset to npm public registry when done
npm config set registry https://registry.npmjs.org
Option 4: file: Protocol
In your consumer project's package.json:
{
"dependencies": {
"@23blocks/contracts": "file:../sdk/packages/contracts",
"@23blocks/react": "file:../sdk/packages/react"
}
}
Releasing
Automatic Release (CI/CD)
Pushing to main triggers the release workflow:
- Builds all packages
- Runs tests
- Versions packages based on conventional commits
- Generates changelogs
- Publishes to NPM
- Creates GitHub releases
Manual Release
# Dry run to see what would happen
npm run release:dry-run
# Version packages (interactive)
npm run release:version
# Generate changelogs
npm run release:changelog
# Publish to NPM
npm run release:publish
Manual Version Bump
Via GitHub Actions:
- Go to Actions > "Publish Manual"
- Select version type (patch/minor/major/prerelease)
- Optionally add prerelease identifier (alpha, beta, rc)
- Run workflow
Conventional Commits
Use conventional commit format for automatic versioning:
feat: add new feature -> minor version bump
fix: fix a bug -> patch version bump
feat!: breaking change -> major version bump
chore: maintenance work -> no version bump
docs: documentation -> no version bump
Examples:
git commit -m "feat(auth): add MFA support"
git commit -m "fix(search): handle empty results"
git commit -m "feat(react)!: change hook API"
Adding a New Block
-
Generate package:
npx nx g @nx/js:lib block-{name} --directory=packages/block-{name} --bundler=swc -
Update
tsconfig.jsonto add project reference -
Update
tsconfig.base.jsonto add path alias -
Create types, mappers, services following existing patterns
-
Add framework bindings in
@23blocks/angularand@23blocks/react
Debugging
# View dependency graph
npm run graph
# Check what would be affected by changes
npx nx affected:apps --plain
npx nx affected:libs --plain
# Run specific package build with verbose output
npx nx build block-authentication --verbose
CI/CD Secrets Required
For GitHub Actions to publish:
| Secret | Description |
|---|---|
NPM_TOKEN | npm access token with publish permissions |
GITHUB_TOKEN | Auto-provided by GitHub Actions |
To create NPM token:
- Go to npmjs.com > Access Tokens
- Generate new token (Automation type)
- Add to GitHub repo: Settings > Secrets > Actions