English
Documentation
Web

Web

OpenCode can run as a web application in your browser, providing the same powerful AI coding experience without needing a terminal.

Getting Started

Launch the web interface:

opencode web

This starts a local server on 127.0.0.1 with an automatically selected port and opens the application in your default browser.

Security Note: Without OPENCODE_SERVER_PASSWORD set, the server has no security. This is acceptable for local use but required when exposing to the network.

Configuration Options

Port

Specify a custom port:

opencode web --port 4096

Hostname

Bind to all network interfaces:

opencode web --hostname 0.0.0.0

By default, the server binds to 127.0.0.1 (localhost only). Use 0.0.0.0 to allow network access.

mDNS Discovery

Enable local network discovery:

opencode web --mdns

This automatically sets hostname to 0.0.0.0 and advertises the server as opencode.local on your local network.

CORS

Allow additional domains for cross-origin requests:

opencode web --cors https://example.com

Authentication

Protect server access with a password:

OPENCODE_SERVER_PASSWORD=secret opencode web

The username defaults to opencode but can be customized via OPENCODE_SERVER_USERNAME.

Web Interface Features

  • Sessions: View and manage active sessions from the homepage
  • Server Status: Access connected servers via "See Servers" option

Terminal Attachment

Connect a terminal TUI to a running web server:

opencode web --port 4096
opencode attach http://localhost:4096

This allows simultaneous access from both browser and terminal.

Configuration File

Configure server settings in opencode.json:

{
  "server": {
    "port": 4096,
    "hostname": "0.0.0.0",
    "mdns": true,
    "cors": ["https://example.com"]
  }
}

Command-line flags override configuration file settings.