Note: This documentation is for version 1 of the Now platform. For the latest features, please see the version 2 documentation. If you have yet to upgrade, see the upgrade guide.

Deploying Static Apps

‚ÄčNow comes with built-in support for static deployments. It considers all projects that don't have a Dockerfile that launches a server, nor a package.json, a static deployment.

Deploying a static project is still as easy as running a single command:

now

If you want to specify a deployment as static, you can use the following configuration in your now.json file:

{
  "type": "static"
}
  • Single File Rendering: If a deployment only contains one file, Now will render that file instead of showing the directory listing, listing that file. This can be overwritten using renderSingle.
  • Clean URLs: Paths will have the .html extension stripped from them. This can be overwritten using cleanUrls.
  • Default ETag Header: Each file is served with a default (weak) ETag header with the checksum of the file as the value. This can not be overwritten.
  • Directory Listing: For paths that aren't files but directories (not including a default index.html or a single file deployment), Now will render a listing of the files contained within that directory. This can be overwritten using directoryListing.
  • Default CORS Header: Each path is served with a Access-Control-Allow-Origin header with * as the value. This can be overwritten using headers.

Now is equipped with configuration options to change the default behavior listed above. These options help your to configure Now to run your app the way you want.

Those options are as follows:

For more information and usage example for these configuration options, read the Static Deployment Configuration documentation.

Deployments stay around forever if they are not removed using the now remove command.

Unlike dynamic deployments, static deployments are never frozen and are always quickly accessible by visitors.

Static deployments running on Now have the same rules as serve-handler, which is available and open to download, fork, extend, and operate locally during development by importing the module itself into an existing server or using its command line interface.

This gives the ability to preview how static apps will work, using now.json configuration or the same defaults, when deployed to Now without needing to deploy first, leaving no room for unexpected behavior.

There a few steps after deploying a static app that are optional but very helpful.