Deploying
This guide walks you through deploying your Kottster app from local development to a production environment. You'll learn how to prepare your admin panel for deployment and explore common hosting options.
Requirements
Before deployment, ensure your environment meets these prerequisites:
Before you deploy
Step 1: Generate a production secret key
- Go to the Kottster dashboard
- Select your app
- Go to app settings and find the "Production secret key" section
- Click the button "Regenerate secret key" to create a new production secrey key
- Copy this key — you'll need it for your app configuration
Important: By default, your development and production keys are the same. For security reasons, always create a separate production key before deploying.
Step 2: Update your app configuration
We recommend using environment variables to set different secret keys for development and production.
Open app/.server/app.js
file and update it to use separate keys based on the environment, like this:
import { createApp } from '@kottster/server';
import { dataSourceRegistry } from './data-sources/registry';
import schema from '../../app-schema.json';
export const app = createApp({
schema,
secretKey: process.env.NODE_ENV === 'development'
? '<your-dev-secret-key>'
: process.env.SECRET_KEY,
});
app.registerDataSources(dataSourceRegistry);
Note: The
NODE_ENV
variable is set todevelopment
by default when runningnpm run dev
. When you runnpm run start
, it’s set toproduction
.
In production, make sure to set the SECRET_KEY
environment variable to your production secret key.
Running in production
Before starting the app in production mode, you need to build it first:
npm run build
This compiles the app and stores it in the build
directory.
Once built, you can start the app in production mode:
npm run start
You can change the port by setting the PORT
environment variable. By default, it will run on port 5480
.
The NODE_ENV
environment variable is set to production
by default when you run npm run build
and npm run start
. This means that the production app will be optimized for performance and will not support live changes to the code, pages, or configuration.
Run Docker container
Alternatively, you can run your app in a Docker container. Learn more about how to run your Kottster app using Docker on the Quickstart with Docker page.
Deployment options
Kottster is a Node.js app, so you can deploy it to any hosting provider that supports Node.js. Some providers run the app as a traditional server, while others use serverless solutions. The serverless option is easier to set up and usually cheaper, but it might not work for all use cases.