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
Runtime mode:
"web" or "desktop"- web: Production mode with dynamic port allocation
- desktop: Loopback-only mode with fixed defaults
HTTP/WebSocket server port (1-65535)Defaults to
3773 in desktop mode, or dynamically allocated in web mode.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
Current working directory of the server process
State directory path for database, logs, and runtime stateContains:
state.sqlite: SQLite databaselogs/provider/events.log: Provider event logskeybindings.json: Keybindings configuration
Static web asset directory for serving the React UIAuto-resolved from bundled client or monorepo build output. Set to
undefined when using devUrl.Development server URL for proxying/redirecting requestsSet via
VITE_DEV_SERVER_URL environment variable in development.Disable automatic browser opening on startupDefaults to
true in desktop mode, false in web mode.Authentication token required for WebSocket connectionsWhen set, clients must provide this token to establish connections.
Automatically create a project for the current working directory on startup if missingDefaults to
true in web mode, false in desktop mode.Enable server-side logging of outbound WebSocket push trafficDefaults to
true when devUrl is set.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
Current process working directory
Apply OS-specific PATH normalizationEnsures correct binary resolution on macOS and other platforms.
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:Runtime mode:
"web" or "desktop"CLI flag: --modeServer port (1-65535)CLI flag:
--portHost interface to bindCLI flag:
--hostState directory pathCLI flag:
--state-dirDevelopment web server URLCLI flag:
--dev-urlDisable automatic browser openingCLI flag:
--no-browserWebSocket authentication tokenCLI flag:
--auth-token or --tokenAuto-create project from working directoryCLI flag:
--auto-bootstrap-project-from-cwdEnable 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
Default server port:
3773Source: apps/server/src/config.ts:11