SyntaxLabs Documentation
Sign in
On this page

Installing SyntaxDocs

SyntaxDocs is a self-hosted documentation platform with a Markdown editor, versioning, analytics and Discord-powered sign-in and discussions. This guide takes you from a fresh server to a running site.


1. Requirements

Component Version / notes
Node.js 24.15.0
MySQL 8.0 or newer
OS Linux (Required - will not run on any other OS)
HTTPS Required. SyntaxDocs will not start unless Site.Domain begins with https://, and its session cookies are always Secure. Put it behind a TLS reverse proxy such as Nginx or Caddy.
Licence key A SyntaxLabs licence key. The server checks it with syntaxlabs.co.uk when it starts and once a day after that, so it needs outbound internet access.
Discord application Needed for sign-in and comments (see step 4).
Optional: mysqldump / mysql CLI Only needed for npm run backup and npm run restore.

2. Get the files and install dependencies

Download the release archive, extract it and run npm install inside the folder.

cd syntaxdocs
npm install

3. Create the database

Sign in to MySQL as an administrator and create a database and a user just for SyntaxDocs:

CREATE DATABASE syntaxdocs CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'syntaxdocs'@'localhost' IDENTIFIED BY 'a-strong-password';
GRANT ALL PRIVILEGES ON syntaxdocs.* TO 'syntaxdocs'@'localhost';
FLUSH PRIVILEGES;

The schema step below does not create the database itself, so it has to exist first.


4. Create a Discord application

Readers and staff sign in with Discord.

  1. Go to the Discord Developer Portal and click New Application.
  2. Open OAuth2 and copy the Client ID and Client Secret.
  3. Under Redirects, add your callback URL exactly as it will appear:
    https://docs.example.com/auth/discord/callback
    
    It must match Site.Domain plus /auth/discord/callback.
  4. (Optional) To send direct-message notifications to users, open Bot, create a bot and copy its token.
  5. (Optional) To post staff notifications to a channel, create a webhook in that Discord channel (Edit Channel → Integrations → Webhooks) and copy its URL.

SyntaxDocs requests only the identify scope.


5. Configure config.js

Open config.js in the project root and fill in every YOUR_… value.

module.exports = {
  Site: {
    Domain: "https://docs.example.com", // public URL, must be https://, no trailing slash
    Host: "127.0.0.1",                  // 127.0.0.1 behind a local proxy; 0.0.0.0 in containers
    Port: 3000,
    TrustProxy: 1,                      // number of reverse proxies in front of the app
    AllowedOrigins: [],                 // extra origins allowed to submit forms, if any
    SuperAdmins: ["123456789012345678"] // Discord user IDs that get full access
  },
  Tokens: {
    LicenseKey: "YOUR_LICENSE_KEY",
    SessionSecret: "at-least-32-random-characters",
    OAuthDiscordID: "your-discord-client-id",
    OAuthDiscordSecret: "your-discord-client-secret",
    DiscordBotToken: "",   // optional
    DiscordWebhook: ""     // optional, https://discord.com/api/webhooks/...
  },
  Session: { MaxAgeHours: 336 },  // how long users stay signed in (14 days)
  Uploads: { MaxMB: 10 },         // max size of a media upload
  Jobs: { Enabled: true },        // background jobs (scheduled publishing, analytics retention)
  SQL: {
    Host: "localhost",
    Port: 3306,
    Username: "syntaxdocs",
    Password: "a-strong-password",
    Database: "syntaxdocs"
  }
};

Settings reference

Setting Required Notes
Site.Domain ✅ Must start with https://. Used for the Discord callback and origin checks.
Site.Host Address the app listens on. Leave 127.0.0.1 when the proxy is on the same machine.
Site.Port Port the app listens on (default 3000).
Site.TrustProxy Set to 1 behind one proxy. If the app is reachable directly while this is on, visitors can fake their IP. SyntaxDocs warns about this at startup.
Site.SuperAdmins ✅ Your Discord user ID(s). These accounts become Super Administrators each time they sign in. To find your ID, turn on Developer Mode in Discord, right-click your name and choose Copy User ID.
Tokens.LicenseKey ✅ The server will not start without it.
Tokens.SessionSecret ✅ 32 or more random characters. The server will not start without it.
Tokens.OAuthDiscordID / OAuthDiscordSecret ✅* *The site runs without them, but nobody can sign in or comment.
Tokens.DiscordBotToken Turns on opt-in Discord DMs for users.
Tokens.DiscordWebhook Turns on staff notifications posted to a Discord channel.

To generate a session secret:

node -e "console.log(require('crypto').randomBytes(48).toString('base64url'))"

⚠️ Keep config.js private. It holds your licence key, session secret, Discord secret and database password. Never commit it to a public repository.


6. Create the database schema

npm run db:run

This generates migrations from the schema and applies them to your database. (npm run db:push applies the schema directly, without migration files.)

The first time the server starts, it also:

  • adds the automatic updated_at timestamps and the full-text search indexes,
  • seeds the default roles, permissions, documentation version and page templates.

Optional: to load a sample documentation set (useful for trying the editor and Markdown features):

npm run seed:demo

Demo content is only added if the site has no pages yet.


7. Start the server

npm start

A successful start shows the SyntaxDocs banner and:

[Server] Server running on port 3000 is now loaded & Online
[License] ...

The server creates etc/, etc/cache and etc/uploads if they are missing. Uploaded media is stored in etc/uploads.

npm install -g pm2
pm2 start index.js --name syntaxdocs
pm2 save
pm2 startup     # follow the printed instructions to start on boot

Useful commands: pm2 logs syntaxdocs, pm2 restart syntaxdocs, pm2 stop syntaxdocs.


8. Set up HTTPS with a reverse proxy

SyntaxDocs needs HTTPS. Here is a minimal Nginx example (get the certificates from Let’s Encrypt using certbot --nginx):

server {
    listen 80;
    server_name docs.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name docs.example.com;

    ssl_certificate     /etc/letsencrypt/live/docs.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/docs.example.com/privkey.pem;

    client_max_body_size 60m;   # backups can be up to 50 MB; media follows Uploads.MaxMB

    location / {
        proxy_pass         http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header   Host              $host;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

With Caddy, all you need is:

docs.example.com {
    reverse_proxy 127.0.0.1:3000
}

Keep Site.TrustProxy: 1 and Site.Host: "127.0.0.1" so that only the proxy can reach the app.

Local testing: SyntaxDocs will not run over plain http://, even on localhost. To test locally, run a local TLS proxy (for example Caddy with localhost { reverse_proxy 127.0.0.1:3000 }), set Site.Domain to https://localhost, and add https://localhost/auth/discord/callback as a redirect in your Discord application.


9. First sign-in

  1. Open your site and click Sign in with Discord.
  2. If your Discord ID is in Site.SuperAdmins, you are signed in as a Super Administrator.
  3. Open the admin panel at /admin to set up your branding and categories and to write your first page.

To give other people a role, have them sign in once, then run:

npm run user:role -- <discordId> <roleSlug>
# e.g. npm run user:role -- 123456789012345678 editor

Available roles: super_admin, admin, editor, author, viewer. You can also change roles from the admin panel.


10. Maintenance

Task Command
Full backup (database and uploads, saved to backups/<timestamp>/) npm run backup
Restore a backup (replaces the database and uploads, so stop the site first) npm run restore -- backups/2026-01-31_02-00-00 --yes
Re-seed roles, permissions and templates npm run seed
Re-render all published pages (after an update that changes rendering) npm run rerender

Backup options (environment variables):

  • BACKUP_KEEP: how many backups to keep (default 14; 0 keeps all of them).
  • MYSQL_BIN_DIR: the folder that contains mysqldump / mysql, if they are not on your PATH.

Example nightly backup (cron):

0 2 * * * cd /path/to/syntaxdocs && /usr/bin/npm run backup >> backups/backup.log 2>&1

Updating

pm2 stop syntaxdocs
npm run backup
# replace the files with the new release (keep config.js, etc/ and backups/)
npm install
npm run db:run
pm2 start syntaxdocs

Missing database structure is added automatically at startup. Run npm run rerender if the release notes say so.


Troubleshooting

Message Fix
Site.Domain must use https://. Change Site.Domain to your https:// URL and run the site behind a TLS proxy (step 8).
Tokens.SessionSecret must be at least 32 random characters. Generate a secret (step 5).
Tokens.LicenseKey must be set. Add your licence key to config.js.
License error followed by the server exiting The licence key was rejected. Check the key and that it is valid for this domain.
MySQL not reachable yet… retrying / Could not connect to MySQL Check that MySQL is running and that the SQL settings are correct. The server retries 10 times, 3 seconds apart.
The database has no tables yet. Run "npm run db:run" first. Run npm run db:run (step 6).
Discord sign-in (and commenting) is unavailable Set OAuthDiscordID and OAuthDiscordSecret, then restart.
Discord shows “Invalid OAuth2 redirect_uri” The redirect in the Discord portal must exactly match Site.Domain + /auth/discord/callback.
Signing in works but you are immediately signed out The site is being reached over plain HTTP, or the proxy is not sending X-Forwarded-Proto. Check Site.TrustProxy.
“Cross-site request blocked” when saving You are using the site from a URL other than Site.Domain. Use the configured domain, or add the other origin to Site.AllowedOrigins.
Uploads fail with “That file is too large” Raise Uploads.MaxMB, plus client_max_body_size in Nginx.
Written by Ollie Last updated 25 Nov 2026 7 min read