- Overview
- Routing
- Proxy Routes
- React
- Quick Start
- Fetching Data from API
- fetch() API
- Populating Page's Head
- Importing CSS/Sass
- TypeScript
- Excluding Bundle from Client-Side
- Markdown and MDX
- Node.js / JavaScript
- Query Parameters
- POST, PUT, PATCH, DELETE Methods
- Dynamic Routes (Pretty URL Slugs)
- fetch() API
- TypeScript
- Sessions
- CORS and Express Middlewares
- HTML
- Vue
- Svelte
- Static Files
- Python
- Before You Start
- Printing To Console
- JSON Response
- URL Parameters
- Requirements.txt
- Dynamic Routes (Pretty URL Slugs)
- POST Data
- File Upload
- Deployment
- Security
- How Zero Works
Deployment
A Zero app is a regular Node.js server. You should zero build
your project in your build step (after npm install
or yarn
step): Here is an example package.json
:
{"name": "my-zero-app","scripts": {"dev": "zero","build": "zero build","start": "NODE_ENV=production zero"},"dependencies": {"zero": "latest"}}
- We add dependency
zero
, so the cloud builder can installzero
on your server. - Add a
"start"
command and also setNODE_ENV
toproduction
so zero generates minified builds and disabled HMR etc. - Add a
"build"
command to pre-build all files to speed up cold boots. Don't forget to runnpm run build
in your build step (in your Dockerfile,heroku-postbuild
, etc) - If your cloud has an option to set environment variables / config variables (to store secrets, API keys, etc), these variables are automatically passed to your code and can be accessed as you normally would. In node, using
process.env.MY_SECRET
. You should never commit your local.env
file to your code.
After this, you can follow the instructions from your cloud provider for deploying a Node.js app.
Heroku Buildpack
We provide an official Buildpack for Heroku. If you are deploying on Heroku, this is the easiest way.
Changing Server's Port
By default zero runs on port 3000
. You can change this by setting the PORT
environment variable, like this: PORT=8080 zero
Running with Docker
Here is a basic Dockerfile
you can add to your zero application to Docker-ize it:
FROM node:alpine# Install dependencies via apkRUN apk update && apk upgrade \&& apk add --no-cache python python3 g++ make \&& rm -rf /var/cache/apk/*# Install zero globallyRUN npm install --quiet --no-progress --unsafe-perm -g zero# Add current folder to /appADD . /app# Run zero in production modeENV NODE_ENV production# Generate bundlesRUN zero build# Expose portENV PORT 80EXPOSE 80WORKDIR /appCMD ["zero"]