What the Heck is a Meteor Package?

This post will serve as a basic overview of what a package is when talking about the JavaScript framework Meteor.

Packages in Meteor are essentially bundles of useful functionality either created by the Meteor team, or by the Meteor community. A simple example is the twbs:bootstrap package. Adding that to your project will automatically add bootstrap styling. This is the same as manually adding the CSS files into your project, but this way, they are all packaged up nicely and updated for us. I will go over finding and adding packages shortly, but for now here are all the different types:

1. Meteor Platform Packages — These are what the Meteor core is made up of; smaller modular packages that work together to create the framework. Since they are part of the core, you don’t have to install them after you install Meteor and you don’t necessarily need to understand how they all work together–hint: magic. (Blaze, Tracker, DDP)

2. Isomorphic Packages — Isomorphic is a key term of the entire framework and it simply means that it works on both the client and the server. So isomorphic packages (isopacks) are just regular packages that work on your entire app (again, magic).

3. First-party Packages — These are isopacks developed by the Meteor team and come along with Meteor, although you do have to manually add them to your project. (accounts-ui, appcache, less)

4. Third-party Packages — Similar to first-party packages, these are isopacks that can be added to your projects, however, third-party packages are created by the wonderful Meteor community. These can range from wrappers for a front-end technology to new components you can use right away. (twbs:bootstrap, urigo:angular, momentjs:moment)

5. Local Packages — Packages you create yourself and put in the local /packages directory are called local packages. Creating custom packages will be a blog post for another day.

6. NPM Packages — For those who have programmed with Node before, npm (Node.js Packaged Modules) should be fairly familiar. It is important to note that (at the time of this post) you can only use npm modules inside packages, not directly with your Meteor apps.

So now that you know what packages are and the various types, where the heck do you find them? For first-party packages, you can take a look at the Meteor Docs and find a list of the most useful ones. For packages written by the community, the go to resource is Atmosphere where you can find packages as well as their descriptions and download count. You can also use the command line with

meteor search <package-name>

Alright, currently you know what packages are how to find them, but how the heck do you use them? Well, like most things in Meteor, it’s pretty straightforward.

To add a package to your project, make sure you’re in your project directory and type

meteor add <package-name>

For first-party packages, that would simply mean typing something like

meteor add accounts-ui

However, for third-party packages, to prevent name collision, you must type

meteor add <package-creator>:<package-name>

So for the bootstrap package created by the user twbs, you would type

meteor add twbs:bootstrap

Removing a package is as simple as adding, just replace the word add with remove!

From here, you should refer to the specific package’s instructions for adding the features into your app. For some, all you need to do is add the package and restart your app to see the changes take place–such as with twbs:bootstrap. Others, likeaccounts-ui, require you to add a special template ({{> loginButtons}} in this case) to your code to add the new components. Whatever the process, the information provided on Atmosphere will likely help you get started.

Hopefully by now you have learned the basics of what packages are, the different types, and how to find and use them. Now the hard part: deciding which to use in your project!

Thankfully, I am starting a new series called “Meteor Package of the Week” where I will select one (or a couple) packages and review them based on a few points. If you enjoyed this post and are interested in the new series, check it out here and follow me on Twitter!