03
Server Options & Configuration
Server options can be configured via nxpress.config.json (or .js, .ts, .mjs, .cjs) in the project root, or passed directly to nxpress(options) / serve(options).
Configuration Schema Options
All configurable properties accepted by the Nxpress server options schema:
| Option | Type | Default | Description |
|---|---|---|---|
| rootDir | string | process.cwd() | Absolute path to the project root directory. |
| appDir | string | "app" (or "pages") | Directory containing view templates and route files. |
| componentsDir | string | "components" | Directory containing reusable template components. |
| publicDir | string | "public" | Directory for serving static assets via Express static middleware. |
| engine | string | "ejs" | Template engine choice ("ejs", "hbs", "html", "nunjucks", "liquid"). |
| port | number | 3000 | HTTP server port number (can also be set via process.env.PORT). |
| tailwind | boolean | object | true | Automatic Tailwind CSS compilation (true, false, or custom path config). |
| globals | object | {} | Application-wide default global variables injected into all template views. |
| secureEnv | boolean | true | Security flag filtering environment variables exposed to templates via E / env. |
| isDev | boolean | Auto-detected | Development mode flag enabling Hot Reload and live route re-scanning. |
| i18n | object | undefined | Internationalization options (locales, defaultLocale, prefixDefault, localesDir). |
Configuration Example (nxpress.config.json)
nxpress.config.json
{
"$schema": "https://unpkg.com/@nxpress/core@latest/schema.json",
"port": 3000,
"engine": "ejs",
"appDir": "app",
"componentsDir": "components",
"publicDir": "public",
"secureEnv": true,
"i18n": {
"locales": ["fr", "en", "es"],
"defaultLocale": "fr",
"prefixDefault": false
},
"globals": {
"siteName": "My Store",
"author": "Nxpress Team",
"currency": "$"
}
}