Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Publish a Gatsby Theme to npm


    Make your Gatsby theme available for use by anyone in the community by publishing it as an npm package.

    For a written version of this course, check out the Gatsby docs.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: To publish our theme, we need to update a couple of things in package.json. The most important one is that we want to name space our theme. This helps us keep track of who publish it, and it also helps avoid naming collisions.

    Once we've got our theme name space, we need to make sure that we're logged in to npm. We can check this by writing npm whoami. If we're not logged in, it's going to tell us that we need to be logged in and how to do it. We can run npm add user. It's going to ask me for my user name and a password. I have to fill in my email.

    Now that I am logged in, if I run npm whoami, it shows me that I am Jay Lengstorf. With the theme name spaced, and me logged into npm, I am ready to publish. I can change directories into the Gatsby theme event directory. I can run npm publish, and because it's name space, I need to include access public.

    Now, it's published. After publishing, we'll be able to find our theme up on npm at npmjs.com/package and the name of our theme.