Skip to main content
Meteor packages are the primary way to organize and share code. This guide shows you how to create your own packages.

Creating a New Package

1

Generate the package

Use the Meteor CLI to create a new package:
If you plan to publish to Atmosphere, use the format username:my-package where username is your Meteor Developer username.
This generates:
2

Define package metadata

Edit package.js to describe your package:
3

Configure package dependencies

Specify which packages your package needs:
4

Add source files

Add your package code using api.mainModule() or api.addFiles():
5

Export symbols

Make your package’s functionality available to users:
Users import with:
6

Add the package to your app

Real Package Examples

Let’s look at real packages from the Meteor repository:

Simple Package: Tracker

From packages/tracker/package.js:

Complex Package: Accounts Base

From packages/accounts-base/package.js:

Package with npm Dependencies: Mongo

From packages/mongo/package.js:

Build Plugin Package: ECMAScript

From packages/ecmascript/package.js:

Adding Different File Types

JavaScript Files

CSS Files

Sass/Less Files

Assets (Images, Fonts, etc.)

Access from client:
Access from server:

TypeScript Definition Files

Testing Packages

Using Tinytest

Run tests:

Using Mocha

Run tests:

Local Packages

Create a local package for your app:
This creates packages/my-local-package/ in your app. Add it:
Local packages are great for:
  • Internal shared code across your app
  • Testing package development before publishing
  • App-specific functionality that’s well-organized

Using METEOR_PACKAGE_DIRS

Share packages across multiple apps:

Best Practices

  • Patch (1.0.1): Bug fixes
  • Minor (1.1.0): New features, backward compatible
  • Major (2.0.0): Breaking changes
  • Clear README.md
  • API documentation
  • Usage examples
  • Version history

Next Steps

Publishing Packages

Learn how to publish your package to Atmosphere

Package.js API

Complete API reference for package.js

Build Plugins

Create compilers, linters, and minifiers