Creating Meteor Packages

I’ve had a crush on Meteor for about a year now. And have done a few sample apps. Yesterday, I decided to create a meteor package. One of the cool things about Meteor is its smart packages. The smart packages are similar to other package or libraries in other languages, like Ruby Gems or NPM. However, the Meteor packages really appeal to the lazy programmer in me. For example, a social connect oauth (facebook or twitter login) can be added with two lines of code. One line at the command line to add the package, and the other line in the view to display the login buttons. {Oh, lazy programmers everywhere rejoice} So, yesterday, I decided to take a stab at building a package myself. Currently, packages that are not included Meteor’s core are managed by Atmosphere. Here are some basic steps for building your own meteor package.

0. If you haven’t already installed Meteorite, install it.

$ npm install -g meteorite

1. Create your package using the Meteorite scaffold command

$ mrt create-package my-package
$ cd my-package

2. Inside your directory, you’ll find smart.json and package.js. Your smart.json file contains your name, author and other describing data about your package. This file is mainly used by Atmosphere. Here’s an example smart.json:

  "name": "my-package",
  "description": "My package does awesome things",
  "homepage": "",
  "author": "Hadiyah Mujhid (",
  "version": "0.0.1",
  "git": "",
  "packages": {}

The “packages” in the json is where you would place any package dependencies. You should only place packages that are not included in Meteors’ smart packages, basically the only packages that are included here are the ones on Atmosphere.

Your package.js file is a javascript file loaded by your package. It contains “instructions” used by Meteor for your package. Here’s an exampe package.js file

  summary: "My awesome package"

Package.on_use(function(api) {
    api.use('http', ['server']);

    api.add_files('awesome_common.js', ['client', 'server']);
    api.add_files('awesome_client.js', 'client');
    api.add_files('awesome_server.js', 'server');

In this file you include all the packages including Meteor base packages needed. In addition, you specify which of the files you want to load and if they apply to the client or server.

3. After you’ve written the code for your package, it’s time to release it and send it to Atmosphere. (if you haven’t already you will need to create an account on Atmosphere). While in your package’s root directory release and publish your package.

$ mrt release ./
$ mrt publish ./

You will be asked for your Atmosphere credentials when you publish the package at the command line. And voila, that’s how you create a Meteor package.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

About Hadiyah

Practicing loving God, neighbors, and myself daily. Leveraging venture capital to advance racial equity at HBCUvc.