Contributing Components to Servercn
Servercn is a backend component registry for Node.js and TypeScript projects.
This guide explains exactly how to create, structure, validate, and submit a reusable component to the registry.
This guide is strictly for contributing registry components — not core CLI or documentation changes.
Step-by-Step Contribution Guide
Fork & Clone the Repository
Fork the Servercn repository and clone it locally: GitHub Link
Understand Component Structure
Each component must follow the registry structure:
Add Registry
Each component must follow the registry structure:
1. Add Registry Without Variant
2. Add Registry With Variant
I. $schema
- Points to the official Servercn component schema.
- Ensures your configuration is validated automatically.
- If this is missing or incorrect, the component will fail validation.
- Always use the official schema URL.
II. slug
- Unique identifier of the component.
- Must be kebab-case.
- Used internally by CLI commands:
npx servercn-cli add test-componentIII. runtimes
Defines which runtime environments support this component.
- Currently, node is the primary runtime.
- Future runtimes (e.g., bun, deno) may be added.
- Your component must not assume compatibility with unsupported runtimes.
IV. frameworks
Specifies which frameworks the component supports.
- Only define frameworks your templates actually support.
- If you declare express, you must provide valid Express-compatible templates.
- Do not declare frameworks without implementation support.
V. prompt
- Displays a selection message in the CLI.
- Used when your component has multiple variants.
- Keep prompt concise.
- Avoid explanations inside the prompt.
- Prompt should describe a decision (library, strategy, mode).
Example CLI output:
VI. variants
Each key under variants represents a selectable implementation option.
- Key must be kebab-case.
- Each variant must define:
label,templates - Optional but recommended:
dependencies,env
VII. label
- Human-readable name shown in CLI.
- Should clearly describe the variant.
Example for email-provider:
VIII. dependencies
Defines packages automatically installed when the component is added.
- Only include packages required by your templates.
- Do not include unnecessary peer dependencies.
IX. templates
Maps architecture types to template folders.
- If you declare both, you must implement both.
- Template folder paths must exist inside:
-
packages/templates/node/express/component/test-component/
Example:
X. env
Defines required environment variables.
- Only include truly required variables.
- Use clear naming conventions.
- Avoid default secrets inside templates.
Add Templates
Template must follow the folder structure below:
- Follow clean separation of concerns
- Match selected architecture style
- Avoid unnecessary dependencies
- Be production-ready
Test the Component via CLI
Before submitting:
npx servercn-cli add test-component --local--local: Used for testing in the local environment.
Verify:
- No runtime errors
- Files generate correctly
- Architecture mapping works
- Stack selection works
Build the Registry Items
Before opening your pull request, ensure the registry output is generated and up to date.
npx servercn-cli buildWhat This Does:
- Compiles all registry items
- Validates schema structure
- Processes component metadata
- Outputs generated files into:
apps/web/public/sr/
Verification:
- After running the build command:
- Navigate to
apps/web/public/sr/ - Confirm your component/item appears
- Ensure generated JSON reflects your changes
Only proceed with your pull request after confirming the registry output is correct.
Don't forget to run `npx servercn-cli build` before submitting your pull request to ensure the registry output is up to date.
Register in registry.json
Add registry inside:
apps/web/src/data/registry.json
This configuration is used to generate the docs sidebar and display components in the
/componentsroute.
Write Minimal Documentation
Add mdx documentation inside:
apps/web/src/content/docs/express/components/component-slug.mdxKeep documentation concise and technical.
Don't forget to include `mvc_structure` and `feature_structure` in the front matter.
Commit Properly
Use conventional commit format:
feat(component): add password-hashing component
Example:
feat(security-header): add middleware for configuring security headers with Helmet and CORS
Submit a Pull Request
Your PR must include:
- Clear title
- Component summary
- Supported stacks
- Testing confirmation
PR checklist:
- Schema valid
- Templates structured correctly
- CLI tested
- No unrelated changes
- Clean commit history
License
By contributing a component to Servercn, you agree that your contribution will be licensed under the MIT License.
Thank you for contributing to Servercn components 🚀 Your work helps strengthen the Node.js backend ecosystem.