Self-hosting LightCMS requires running a SvelteKit application, connecting a PostgreSQL database, and configuring a GitHub App for repository access. Self-hosting gives you full control over your infrastructure and data flow, but it also makes you responsible for updates, backups, secrets, and uptime.

Verify each command and environment variable against the current LightCMS repository before deploying to production.

Components you need

ComponentPurposeRequired
PostgreSQLStores application data such as users, sessions, and installationsYes
GitHub AppHandles GitHub authentication and repository accessYes
SMTP providerSends magic-link sign-in emailsDepends on auth setup
OpenAI-compatible APIPowers AI copilot featuresNo
Speech-to-text APIPowers voice dictationNo
Image/CDN storageStores uploaded mediaDepends on media setup

1. Prerequisites

  • Runtime: Node.js or Bun matching the versions required by the LightCMS repository.
  • PostgreSQL with TLS: A TLS-capable PostgreSQL connection.
  • GitHub account: Needed to create and install your GitHub App.
  • SMTP credentials: Optional, required only if you enable magic-link email sign-in.

2. Create and configure the GitHub App

Create a GitHub App in your GitHub account or organization settings. Configure the callback, setup, and webhook URLs to match your deployed domain:

SettingExample value
Homepage URLhttps://<your-domain>
Callback URLhttps://<your-domain>/api/auth/callback/github
Setup URLhttps://<your-domain>/github/setup
Webhook URLhttps://<your-domain>/api/github/webhook

Grant only the repository permissions LightCMS needs. After creation, record the App ID, client ID, client secret, webhook secret, and private key.

3. Configure environment variables

Create a .env file locally or configure environment variables in your hosting platform:

# Authentication
BETTER_AUTH_SECRET="<random-secret>"
BETTER_AUTH_URL="https://<your-domain>"

# Database
DATABASE_URL="postgresql://user:password@host:5432/lightcms?sslmode=require"

# GitHub App
GITHUB_APP_ID="123456"
GITHUB_CLIENT_ID="Iv1.xxxxxxxxxxxx"
GITHUB_CLIENT_SECRET="<github-app-client-secret>"
GITHUB_WEBHOOK_SECRET="<webhook-secret>"
GITHUB_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----"

Generating secrets

Generate BETTER_AUTH_SECRET and GITHUB_WEBHOOK_SECRET using either OpenSSL or Node.js:

openssl rand -hex 32
# or
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

Image and CDN uploads

Images pasted or uploaded in the editor are sent to a Chevereto-compatible upload API. Hosted options include FreeImage.host and ImgBB, or you can run your own Chevereto instance.

CDN_URL="https://freeimage.host/api/1/upload"
CDN_KEY="<cdn-api-key>"

CDN_KEY is sent as the key query parameter unless CDN_URL already contains one. If the upload fails or the variables are unset, LightCMS falls back to embedding the image in the document as a base64 data: URL. This works for quick testing, but it bloats your Markdown files, so configure a CDN for real use.

Optional: Voice-to-text, AI, and analytics

You can enable voice dictation using Wit.ai or any OpenAI-compatible transcription API (such as Groq, AssemblyAI, ElevenLabs, Deepgram, or Sarvam).

# Wit.ai
WIT_AI_TOKEN="<server-access-token>"
WIT_AI_CLIENT_TOKEN="<client-access-token>"

# OpenAI-compatible AI & Speech
OPEN_AI_ENDPOINT=""
OPEN_AI_MODEL=""
OPEN_AI_APIKEY=""
SPEECH_ENDPOINT=""
SPEECH_MODEL=""
SPEECH_API_KEY=""

# PostHog Analytics (optional)
PUBLIC_POSTHOG_KEY="<your-posthog-project-key>"
PUBLIC_POSTHOG_HOST="<your-posthog-host>"

4. Set up the database

LightCMS uses Drizzle ORM. The schema lives in src/lib/server/db/schema.ts, and migrations are generated into the drizzle directory. With DATABASE_URL set, apply the migrations:

bun run db:migrate

During local development you can push the schema straight to the database without migration files:

bun run db:push

Other database scripts:

CommandDescription
bun run db:generateGenerate a migration after editing the schema
bun run db:studioBrowse and edit your data in Drizzle Studio

5. Run locally

bun run dev

LightCMS GitHub App permissions

Detailed repository permissions

LightCMS will be available at http://localhost:5173. Set BETTER_AUTH_URL to this address and sign in with GitHub for the first time.

Testing webhooks locally

GitHub cannot deliver webhooks to localhost, so forward them through smee.io:

  1. Create a channel at smee.io and copy its URL.

  2. Set WEBHOOK_PROXY_URL in .env to that URL (WEBHOOK_PROXY_URL="https://smee.io/<your-channel>").

  3. Set the Webhook URL in your GitHub App settings to the same URL.

  4. Run the bot in a second terminal:

    bun run bot:start

The bot registers the same handlers as the production endpoint: content validation on push, review comments and labels on pull_request, and installation logging.

6. Production deployment

LightCMS is built with SvelteKit, so Vercel, Netlify, and Cloudflare Workers are supported deployment targets:

  1. Import your Git repository into your deployment platform.
  2. Add every required environment variable from step 3 in your project settings, and set BETTER_AUTH_URL to your production URL.
  3. Deploy and test the full flow: sign in, connect a repository, edit a file, commit a change, and confirm your static site build runs.

To verify the production build locally before deploying:

bun run build
bun run preview