---
title: How to Write a JavaScript Library
date: 2015-09-08
description:
  There are so many reasons to open source your code. But knowing how to do it
  can be a real challenge.
meta:
  keywords:
    - javascript
    - open source
bannerCloudinaryId: kentcdodds.com/content/blog/how-to-write-a-javascript-library/banner
---

There's a lot of steps to creating and maintaining an open source library. It's
like becoming a parent. Open source libraries _can be_ quite demanding,
impatient, and time consuming.

Some libraries are small enough that they're pretty easy to create and don't
need to be maintained when they're "done." However, once your lib gets to be
more than just a few dozen lines of code, you're going to be faced with some
challenges in developing, documenting, releasing, updating, and maintaining your
library.

Even with all of these challenges, it's still totally worth it to open source
your library. Whether it's the next big JavaScript framework or a simple
utility, we welcome your contributions.

#### Getting started...

I've created a free series on egghead.io that's intended to help you open source
your stuff. I start at the very very basics and get you up to speed with the
latest and greatest practices for developing open source libraries. The series
is still being developed and there are a lot of lessons in the pipeline waiting
to be published. But here are a few of the concepts you'll learn from this
series:

- Setting up GitHub for hosting
- Setting up npm for publishing
- Creating the lib and adding dependencies
- Releasing to npm and GitHub
- Releasing new and beta versions
- Unit testing and code coverage
- Setting up continuous integration
- Automating the release process
- Code linting
- Adding githooks to help prevent mistakes
- Getting contributors
- Adding a transpiler for ES6 support
- Creating an Isomorphic/Universal/Portable JavaScript Library
- Documentation
- And more!

Not all libraries need all of this, but many would benefit from having this. If
you're curious, check out the (free) lesson series on egghead.io:
[How to Write a JavaScript Library](https://egghead.io/courses/how-to-write-an-open-source-javascript-library).
Start writing more open source JavaScript today! 👍

If you have any recommendations or questions, catch me on
[Twitter](https://twitter.com/kentcdodds).
