This guide covers the complete process of building, testing, and packaging your Jan extension for distribution.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/janhq/jan/llms.txt
Use this file to discover all available pages before exploring further.
Project Structure
A typical Jan extension project structure:Configuration Files
package.json
package.json
The
productName field is displayed in Jan’s UI. The name field is used internally.tsconfig.json
tsconfig.json
rolldown.config.mjs
rolldown.config.mjs
Building Your Extension
Development Build
For development, use the build command with watch mode:Production Build
For production, create an optimized build:Verify Build Output
Check thatdist/index.js was created:
Testing Your Extension
Local Testing
-
Build your extension:
-
Create a test package:
-
Install in Jan:
- Open Jan > Settings > Extensions
- Click Manual Installation
- Select your
.tgzfile
-
Enable Developer Tools:
- Go to Help > Toggle Developer Tools
- Check Console for logs and errors
Debugging
Add console logs throughout your extension:Test Event Handling
Packaging for Distribution
Create Package
Run the publish script:myorg-my-extension-1.0.0.tgz in your project root.
Package Contents
Your package includes:dist/- Compiled JavaScriptpackage.json- Package metadataREADME.md- Documentation
Version Management
Semantic Versioning
Follow semver for version numbers:- MAJOR (1.0.0): Breaking changes
- MINOR (1.1.0): New features, backward compatible
- PATCH (1.0.1): Bug fixes, backward compatible
Update Version
Update version inpackage.json:
Distribution
Share Your Extension
- GitHub Releases: Upload
.tgzto GitHub releases - npm Registry: Publish to npm (if public)
- Direct Distribution: Share
.tgzfile directly
npm Publishing
To publish to npm:GitHub Release
-
Create a Git tag:
-
Create GitHub release:
- Go to your repository’s Releases
- Click “Create a new release”
- Select your tag
- Upload your
.tgzfile - Add release notes
Example: Complete Build Script
Add topackage.json:
Real-World Example: Conversational Extension
Here’s the complete build configuration from Jan’s built-in conversational extension:package.json
Best Practices
Use TypeScript
Use TypeScript
TypeScript provides type safety and better IDE support. All Jan core APIs are fully typed.
Keep bundle size small
Keep bundle size small
- Use external dependencies when possible
- Avoid large libraries
- Tree-shake unused code
Handle errors gracefully
Handle errors gracefully
Clean up resources
Clean up resources
Version your APIs
Version your APIs
If your extension exposes APIs, version them:
Document your extension
Document your extension
Include a comprehensive README.md with:
- Installation instructions
- Configuration options
- Usage examples
- Changelog
Troubleshooting
Build fails with module errors
Build fails with module errors
Ensure all dependencies are installed:
Extension doesn't load in Jan
Extension doesn't load in Jan
Check:
package.jsonhas correctmainfielddist/index.jsexists- No syntax errors in console
- Extension is enabled in Jan settings
Types not working
Types not working
Install type definitions:Update
tsconfig.json:Package is too large
Package is too large
Exclude unnecessary files in Avoid bundling
package.json:node_modules by marking dependencies as external.Next Steps
Core API
Explore the complete API reference
Examples
View real extension examples
Extension Template
Start from the official template
Community
Join the Jan community