Skip to main content
The init command creates a .env file with your database and server configuration through an interactive prompt.

Usage

oforum init

Interactive Prompts

The command prompts you for two configuration values:

Database URL

Database URL (default: postgres://localhost:5432/oforum?sslmode=disable)
>
Database URL
string
PostgreSQL connection string in the format:
postgres://[user[:password]@]host[:port]/database[?options]
Press Enter to use the default value for local development.

Port

Port (default: 8080)
>
Port
string
default:"8080"
HTTP server port number. Press Enter to use the default port 8080.

Output Format

The generated .env file contains:
.env
DATABASE_URL=postgres://localhost:5432/oforum?sslmode=disable
PORT=8080

Overwrite Behavior

If a .env file already exists, you’ll be prompted for confirmation:
⚠ .env already exists. Overwrite? [y/N]
 .env already exists. Overwrite? [y/N] y

  oforum init

Database URL (default: postgres://localhost:5432/oforum?sslmode=disable)
> postgres://db.example.com:5432/prod_forum

Port (default: 8080)
> 3000

 Created .env

DATABASE_URL=postgres://db.example.com:5432/prod_forum
PORT=3000

Run oforum to start the server.

Examples

Local Development

Use defaults for local PostgreSQL:
oforum init
# Press Enter twice to accept defaults
Output:
  oforum init

Database URL (default: postgres://localhost:5432/oforum?sslmode=disable)
>
Port (default: 8080)
>

✓ Created .env

DATABASE_URL=postgres://localhost:5432/oforum?sslmode=disable
PORT=8080

Run oforum to start the server.

Production Deployment

Configure for remote database:
oforum init
Enter values:
Database URL: postgres://user:[email protected]:5432/oforum_prod?sslmode=require
Port: 8080

Custom Port

Use local database on different port:
oforum init
Enter:
Database URL: [press Enter for default]
Port: 3000

Manual Configuration

You can also create or edit .env manually:
.env
DATABASE_URL=postgres://localhost:5432/oforum?sslmode=disable
PORT=8080
The .env file is loaded automatically by oforum serve and other commands. You don’t need to export variables manually.

Connection String Format

Basic Format

postgres://localhost:5432/oforum

With Authentication

postgres://username:password@localhost:5432/oforum

With SSL

postgres://user:[email protected]:5432/oforum?sslmode=require

Without SSL (Local Development)

postgres://localhost:5432/oforum?sslmode=disable
Always use sslmode=require in production to encrypt database connections.

SSL Mode Options

The sslmode parameter controls PostgreSQL SSL behavior:
  • disable - No SSL (local development only)
  • require - Require SSL but don’t verify certificate
  • verify-ca - Require SSL and verify CA certificate
  • verify-full - Require SSL and verify certificate + hostname
If your connection string doesn’t include sslmode, oForum automatically appends sslmode=disable for local connections. In production, explicitly set sslmode=require.

Next Steps

After creating your .env file:
  1. Start the server (migrations run automatically):
    oforum
    
  2. Seed demo data (optional for development):
    oforum seed
    
  3. Access the forum at http://localhost:8080

Build docs developers (and LLMs) love