Lowdefy
v3.23.3/Deployment/Deploy with Node.js/

Deploy with Node.js

A production Lowdefy server that runs using Node.js is published on npm as @lowdefy/server-node.

Running the server

Step 1 - Create a package.json file

To run the server in a Lowdefy project, first initialise a Node.js project by creating a package.json file in the root of your project. To do this, you can run

npm init

Step 2 - Add the @lowdefy/server-node package to your project as a dependency

To add the server as a dependency, run

npm install @lowdefy/server-node --save --save-exact

Step 3 - Add the Lowdefy CLI to you project as a dev dependency.

To add the server as a dependency, run:

npm install lowdefy --save-dev --save-exact

Step 4 - Add the build and start scripts.

Add the following to the scripts section in your package.json file:

"scripts": {
  "init": "lowdefy init",
  "build": "lowdefy build",
  "start": "lowdefy-server"
},

Step 5 - Init a Lowdefy project

Run:

npm run init

Step 6 - Add the public files:

Create a folder called public in your project directory and add the Lowdefy public files found here (or add your own logos and files).

Step 7 - Build the Lowdefy project

Build the Lowdefy configuration files in the project by running:

npm run build

Step 8 - Start the server

To start the server, run:

npm run start

Configuration

The Lowdefy server can be configured using command-line arguments or environment variables. The command-line arguments take precedence over the environment variables.

The following command-line arguments can be specified:

  • --build-directory: The directory of the built Lowdefy configuration (The output of lowdefy build, usually found at ./.lowdefy/build in your project repository). The default is ./.lowdefy/build.
  • --port: The port at which to run the server. The default is 3000.
  • --public-directory: The directory of the public assets to be served. The default is ./public.

The following environment variables can be specified:

  • LOWDEFY_SERVER_BASE_PATH: Set the base path to serve the Lowdefy application from. This will serve the application under https://example.com/<base-path>instead of https://example.com, and all pages under https://example.com/<base-path>/<page-id> instead of the default https://example.com/<page-id>.
  • LOWDEFY_SERVER_BUILD_DIRECTORY: The directory of the built Lowdefy configuration (The output of lowdefy build, usually found at ./.lowdefy/build in your project repository). The default is ./.lowdefy/build.
  • LOWDEFY_SERVER_PORT: The port at which to run the server. The default is 3000.
  • LOWDEFY_SERVER_PUBLIC_DIRECTORY: The directory of the public assets to be served. The default is ./public.