Ludicord
Guide 17 · Production

Configuration

Control Discord, React, build, server, and WebSocket behavior from one file.

Ludicord 3.1.0Public source 20c4889

ludicord.config.mjs defines the contract shared by development, build, and production. Use defineConfig() for editor checks and keep environment-specific credentials in environment variables.

#Start from the generated configuration

ludicord.config.mjsjs
1import { defineConfig } from "ludicord/config";
2
3export default defineConfig({
4 discord: {
5 clientId: process.env.LUDICORD_DISCORD_CLIENT_ID,
6 scopes: ["identify", "guilds"],
7 auth: { required: true, session: "encrypted-cookie" },
8 },
9 activity: { defaultEmbed: "home", outsideDiscord: "allow" },
10 react: { strictMode: true },
11 server: { port: 3000, host: "0.0.0.0" },
12 websocket: { enabled: true },
13});

Changing the configuration during development triggers a controlled runtime restart because host, auth, build, and transport settings can affect every route. Client, API, and WebSocket source edits do not require that restart.

#Discord and Activity options

OptionDefaultMeaning
discord.clientIdEnvironmentDiscord Application ID
discord.scopes["identify"]OAuth2 scopes requested by the SDK
discord.auth.requiredtrueCompletes auth before normal UI
discord.auth.proxyVerificationfalseRequires verified Discord proxy signatures for API requests
discord.auth.activityInstanceVerificationfalseRequires a verified Activity instance in session context
activity.defaultEmbed"home"Initial embed route
activity.outsideDiscord"error"Behavior in a normal browser: error, mock, or allow

Use allow for an honest limited browser preview. Use mock only for intentional development fixtures. Production behavior should not silently invent Discord context.

#React and build options

OptionDefaultMeaning
react.strictModetrueEnables React development checks
build.clientAssetWarningLimit512000Warns when one emitted client asset exceeds this byte size

Strict Mode can expose missing effect cleanup. Fix the effect rather than disabling the check for the whole project.

#HTTP server options

OptionDefaultMeaning
server.port3000Listening port; PORT may override it
server.host"0.0.0.0"Listening interface; HOST may override it
server.allowedHoststrueAll hosts or an explicit hostname list
server.limits.body"2mb"Maximum API request body
server.requestTimeout30000API route timeout in milliseconds
server.shutdownTimeout10000Graceful shutdown window

Restrict allowedHosts in environments where requests can reach the server through multiple untrusted hostnames.

#WebSocket options

OptionDefaultMeaning
websocket.enabledtrueEnables /ws routes
heartbeatInterval30000Server ping interval
maxPayload1048576Maximum message bytes
compressionfalseEnables per-message deflate
maxMessagesPerSecond120Per-client inbound event rate
reconnect.attempts10Client reconnect attempts
reconnect.initialDelay500Initial retry delay
reconnect.maxDelay10000Backoff ceiling

Lower limits for small event protocols. Enable compression only after measuring CPU and bandwidth for realistic payloads.

#Validate configuration early

Ludicord validates types and bounds before starting. Invalid ports, timeouts, limits, scopes, host lists, or reconnect ranges fail with a LUDICORD0004 configuration error instead of becoming an unstable runtime.

#Next step

Open Environment variables to separate deploy-specific values and server credentials from this checked configuration.