Skip to main content
The Config struct is the root configuration object for a workerd instance. It defines services, sockets, and runtime behavior.

Structure

services
List<Service>
required
List of named services defined by this server. Services are not reachable until configured through a Socket or binding.If no service named “internet” is defined, one is created implicitly representing access to public internet servers.
sockets
List<Socket>
List of sockets on which the server will listen and expose services.
v8Flags
List<Text>
Command-line flags to pass to V8, like --expose-gc. Use with caution as flags can have unpredictable effects and may change between V8 versions.
extensions
List<Extension>
Extensions provide capabilities to all workers. Extensions are typically prepared separately and late-linked using this config field.
autogates
List<Text>
List of autogates to enable. Autogates are used to conditionally enable features and changes in workerd.
logging
LoggingOptions
Console and stdio logging configuration options.

Logging options

logging.structuredLogging
Bool
default:"false"
If true, logs are emitted as JSON for structured logging. When false, logs use the traditional human-readable format.
logging.stdoutPrefix
Text
Custom prefix for process.stdout. Defaults to stdout: .
logging.stderrPrefix
Text
Custom prefix for process.stderr. Defaults to stderr: .

Example

using Workerd = import "/workerd/workerd.capnp";

const config :Workerd.Config = (
  services = [
    ( name = "main",
      worker = (
        modules = [
          (name = "worker.js", esModule = embed "worker.js")
        ],
        compatibilityDate = "2024-01-01",
      )
    )
  ],
  sockets = [
    ( name = "http",
      address = "*:8080",
      http = (),
      service = "main"
    )
  ]
);

Capability-based design

The configuration follows capability-based security principles. By default, workers have no privileged resource access. You must explicitly declare “bindings” to grant access to specific resources, giving the worker a JavaScript API object pointing to that resource. This allows full control over which resources each worker can access through configuration alone.

Build docs developers (and LLMs) love