Overview
The T3 Code server uses a layered configuration system powered by Effect, with support for CLI flags, environment variables, and runtime defaults.ServerConfig
Core runtime configuration service that defines process-level server settings and networking parameters. Service Tag:t3/config/ServerConfig
Source: apps/server/src/config.ts:36
ServerConfigShape
RuntimeMode
required
Runtime mode:
"web" or "desktop"- web: Production mode with dynamic port allocation
- desktop: Loopback-only mode with fixed defaults
number
required
HTTP/WebSocket server port (1-65535)Defaults to
3773 in desktop mode, or dynamically allocated in web mode.string | undefined
Host interface to bind
undefined: Bind to all interfaces (web mode default)"127.0.0.1": Loopback only (desktop mode default)"0.0.0.0": Explicit wildcard binding- Any valid IP or hostname
string
required
Current working directory of the server process
string
required
State directory path for database, logs, and runtime stateContains:
state.sqlite: SQLite databaselogs/provider/events.log: Provider event logskeybindings.json: Keybindings configuration
string | undefined
Static web asset directory for serving the React UIAuto-resolved from bundled client or monorepo build output. Set to
undefined when using devUrl.URL | undefined
Development server URL for proxying/redirecting requestsSet via
VITE_DEV_SERVER_URL environment variable in development.boolean
required
Disable automatic browser opening on startupDefaults to
true in desktop mode, false in web mode.string | undefined
Authentication token required for WebSocket connectionsWhen set, clients must provide this token to establish connections.
boolean
required
Automatically create a project for the current working directory on startup if missingDefaults to
true in web mode, false in desktop mode.boolean
required
Enable server-side logging of outbound WebSocket push trafficDefaults to
true when devUrl is set.string
required
Path to keybindings configuration fileDerived from
stateDir: {stateDir}/keybindings.jsonCliConfig
Startup-only service providing bootstrap helpers used during server layer construction. Service Tag:t3/main/CliConfig
Source: apps/server/src/main.ts:70
CliConfigShape
string
required
Current process working directory
Effect<void>
required
Apply OS-specific PATH normalizationEnsures correct binary resolution on macOS and other platforms.
Effect<string | undefined>
required
Resolve static web asset directory for server modeSearches in order:
- Bundled client:
{dirname}/client/index.html - Monorepo build:
../../web/dist/index.html
undefined if no valid bundle is found.Environment Variables
The server configuration can be controlled via environment variables:string
Runtime mode:
"web" or "desktop"CLI flag: --modenumber
Server port (1-65535)CLI flag:
--portstring
Host interface to bindCLI flag:
--hoststring
State directory pathCLI flag:
--state-dirURL
Development web server URLCLI flag:
--dev-urlboolean
Disable automatic browser openingCLI flag:
--no-browserstring
WebSocket authentication tokenCLI flag:
--auth-token or --tokenboolean
Auto-create project from working directoryCLI flag:
--auto-bootstrap-project-from-cwdboolean
Enable WebSocket event loggingCLI flag:
--log-websocket-events or --log-ws-eventsCLI Usage
Configuration Resolution
Configuration values are resolved in the following priority order (highest to lowest):- CLI Flags: Explicit command-line arguments
- Environment Variables:
T3CODE_*prefixed variables - Mode Defaults: Defaults based on
--modesetting - Built-in Defaults: Hardcoded fallback values
Example Layer Construction
Static Utilities
resolveStaticDir
Source:apps/server/src/config.ts:62
Resolve the static web asset directory by searching for bundled or monorepo builds.
Effect<string | undefined>
Constants
number
Default server port:
3773Source: apps/server/src/config.ts:11