Static Builder (@now/static)

Status: Stable

This module is used to include source files as Build outputs. You can think of @now/static as a module that copies over files.

When to Use It

When you deploy a project that has no Builds we serve the sources directly.

For example, when you deploy a single file (now photo.jpg) or a directory with no now.json and/or no builds inside it.

However, if you define a build step, Now will only include its outputs in the resulting deployment, as a security precaution to avoid serving unintended files to the public.

In those circumstances, if you want to include unmodified source files as outputs, you can use @now/static.

How to Use It

Suppose you have a directory with three files:

  • function.js - A Node.js function you want to expose.
  • index.html - A source file you want to serve without modification.
  • - A source file you never want to serve.

If your now.json looks like this:

  "version": 2,
  "builds": [{ "src": "function.js", "use": "@now/node" }]

Then only the build outputs of @now/node will be included: a lambda.

To see for yourself, check the resulting deployment Also, the source code of the deployment can be checked by appending /_src e.g.

To also serve index.html, you'll want to add a @now/static build:

  "version": 2,
  "builds": [
    { "src": "function.js", "use": "@now/node" },
    { "src": "index.html", "use": "@now/static" }

You can see the resulting deployment in action here:

Technical Details


You can specify any file or set of files as the src of a build that uses @now/static.