Getting started with development using Now is simple and only requires a single command - now dev
.
now dev
is the single command development experience created with the aim of maximizing your productivity by simulating our Now platform locally.
To get started with now dev
, you will need 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).
now dev
requires 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.Key Concepts
Development Secrets
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:
.env
contains environment variables used during runtime.env.build
contains environment variables used during buildtime
now.json
file.Production-Like Environment, Locally
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.
Out of the box, now dev
simulates the same model for routing, concurrency, and execution, and even accepts the exact same now.json
configuration.
Custom Development Environment
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 @now/static-build
Builder.
For more information on this, see the @now/static-build
Builder documentation.
Your First Project
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:
apollo
bash
create-elm-app
create-react-app
docz
express
express-twitter-dreamify
❯ gatsby
go
go-image-to-ascii
gridsome
html-minifier
jekyll
markdown
mdx-deck
(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.
now dev
.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!
Read More
Extend your projects with all that Now offers: