Configuration
Docunara is configured through environment variables defined in the .env file at the project root. Copy .env.example to .env to get started:
cp .env.example .env
The dotenv library reads inline comments (e.g., VALUE=foo # comment) as part of the value. Always place comments on a separate line above the variable, never after the value on the same line.
# This is the correct way to comment
PORT=3000
PORT=3000 # This comment becomes part of the value — WRONG
Server Port Settings
| Variable | Default | Description |
|---|---|---|
PORT | 3000 | Docusaurus development server port |
API_PORT | 3001 | Docunara API server port |
Legacy Authentication
When the database is disabled (DB_ENABLED=false), you can use a shared bearer token for API authentication instead of username/password login:
| Variable | Default | Description |
|---|---|---|
EDITOR_SECRET | (empty) | Shared bearer token for API access. Only applies when DB_ENABLED=false and ADMIN_PASSWORD is not set. Clients include this token in the Authorization: Bearer <token> header. |
When DB_ENABLED=false, the authentication mode is determined in this order:
- If
ADMIN_PASSWORDis set → JWT-based login (admin ID or email) - Else if
EDITOR_SECRETis set → Bearer token authentication - Else → open access (no authentication)
Admin Account
The admin account is used for editor authentication in all modes. Users can log in with either their ID or email.
| Variable | Default | Description |
|---|---|---|
ADMIN_ID | (empty) | Admin login ID (e.g., admin) |
ADMIN_EMAIL | (empty) | Admin email address |
ADMIN_PASSWORD | (empty) | Admin password. If empty and EDITOR_SECRET is also empty, no authentication is required. |
When DB_ENABLED=false:
ADMIN_PASSWORDempty andEDITOR_SECRETempty → editor is open to anyone (no authentication)ADMIN_PASSWORDset → login is required; user can log in withADMIN_IDorADMIN_EMAILEDITOR_SECRETset (withoutADMIN_PASSWORD) → API requires the bearer token
When DB_ENABLED=true:
- An admin account is created in the database on first run using these credentials
- This is the only account available unless a valid license enables user management
Change the default admin credentials immediately in production environments.
Database Settings
Enable SQLite for document search:
| Variable | Default | Description |
|---|---|---|
DB_ENABLED | false | Set to true to enable SQLite database and search |
DB_PATH | ./data/editor.db | Path to the SQLite database file |
JWT_SECRET | — | Secret key for signing JWT tokens. Must be changed in production. |
JWT_EXPIRES_IN | 1h | Access token expiration duration |
JWT_REFRESH_EXPIRES_IN | 7d | Refresh token expiration duration |
What the Database Enables
- Document search — full-text search across all documentation files
- JWT authentication — secure token-based auth (replaces simple credential check)
Enabling the Database
- Set
DB_ENABLED=truein your.envfile - Set a strong, unique
JWT_SECRETvalue - Configure the admin account credentials
- Start the server — the database and tables are created automatically
License Settings
| Variable | Default | Description |
|---|---|---|
LICENSE_FILE | (empty) | Path to a license certificate file. Required for premium features (user management, alternative DB backends). |
See Licensing for details on the license policy.
AI Chat Settings
Configure the built-in AI writing assistant. AI Chat is enabled automatically when an API key is provided.
| Variable | Default | Description |
|---|---|---|
AI_PROVIDER | openai | AI provider: openai or anthropic |
AI_APIKEY | (empty) | API key for the AI provider. AI Chat is disabled when empty. |
AI_MODEL | (auto) | Model name. Defaults to gpt-4o-mini (OpenAI) or claude-sonnet-4-20250514 (Anthropic). |
AI_SYSPROMPT | (built-in) | Custom system prompt for the AI assistant. Uses a documentation-focused default when empty. |
See AI Chat for usage details and feature availability.
Feature Availability Summary
| Configuration | Auth Method | Search | User Management |
|---|---|---|---|
DB_ENABLED=false, no password, no secret | No authentication | No | No |
DB_ENABLED=false, EDITOR_SECRET set | Bearer token | No | No |
DB_ENABLED=false, ADMIN_PASSWORD set | JWT (admin ID or email login) | No | No |
DB_ENABLED=true | JWT (admin only) | Yes | No |
DB_ENABLED=true + valid LICENSE_FILE | JWT (multi-user) | Yes | Yes |
Example .env File
# Server Ports
PORT=3000
API_PORT=3001
# Legacy bearer token (only when DB_ENABLED=false and no ADMIN_PASSWORD)
EDITOR_SECRET=
# Database
DB_ENABLED=true
DB_PATH=./data/editor.db
# JWT (change in production!)
JWT_SECRET=my-secure-random-secret-key
JWT_EXPIRES_IN=1h
JWT_REFRESH_EXPIRES_IN=7d
# Admin Account
ADMIN_ID=admin
ADMIN_EMAIL=admin@mycompany.com
ADMIN_PASSWORD=change-me-immediately
# License certificate (empty = development mode)
LICENSE_FILE=
# AI Chat
AI_PROVIDER=openai
AI_APIKEY=
AI_MODEL=
AI_SYSPROMPT=