Getting started with development using Now is simple and only requires a single command -
now dev is the single command development experience created with the aim of maximizing your productivity by simulating our Now platform locally.
now devrequires Now 2.0 and the latest version of the Now CLI to work. If you are currently using Now 1.0, you should consider upgrading.
In order to simulate performance that is as close to production as possible,
now dev will not automatically trigger a rebuild when your source files change.
However, triggering a force-reload in your browser will wipe the cache and issue a rebuild.
When working on a project with
now dev, it is extremely important that you do not use any production secrets (like your database credentials, for example).
Instead, you should use secrets that are specific to the development environment and cannot cause any production damage. Those can be set in one of two files:
.envcontains environment variables used during runtime
.env.buildcontains environment variables used during buildtime
By mimicking the behavior of the Now platform in almost every way,
now dev decreases the chance of unexpected surprises when deploying to a minimum.
If your project is built using the
@now/static-build Builder or you are going to set up a project that is built statically when deployed; you can define custom development behavior for what
now dev and its associated environment should attach to when you are developing locally.
To do this, you can use a
now-dev script inside of a
package.json that is an entrypoint of the
For more information on this, see the
@now/static-build Builder documentation.
This guide shows you how to get started with local development in Now in under a minute.
To get your first project up and running, you will be using the Now CLI. If you have not installed it yet, please refer to the installation instructions (otherwise, run
yarn add global now if Node.js is installed).
For your convenience, we have created a number of examples that are ready to use with
now dev. To create a project using an example, enter the following:
This will load a list of examples for you to choose from:
(Move up and down to reveal more choices)
Selecting a project using the
now init command.
For this guide we'll use Gatsby, you're free to use whichever project you'd like to, however.
Once you have found a project you want to use, hit enter (if the list does not include what you are looking for, read about adding it). You will then see a directory created containing the project starter you selected:
> Success! Initialized "gatsby" example in ~/gatsby.
Next, you should follow the option given in the terminal and use the following command:
After a short build you will see a success message, you are now developing locally with Now!
Extend your projects with all that Now offers: