noxt-server
v0.1.14
Published
Server for noxt-js-middleware with CLI and config support
Downloads
26
Maintainers
Readme
noxt-js
A zero-config JSX web server powered by Express and noxt-js-middleware.
Run it with npx noxt-js and drop .jsx files into your views/ folder — routes are created automatically.
No React required. No heavy framework. Just JSX + Express.
Installation
npm install noxt-jsor run it directly without installing:
npx noxt-jsQuick Start
npx noxt-jsBy default, this will:
- Serve pages from
./views/ - Start an HTTP server on port
3000 - Look for configuration in
noxt.config.yaml(optional)
Configuration
noxt-js reads options from noxt.config.yaml in your project root, or from CLI flags.
CLI flags override config file values.
Example noxt.config.yaml:
port: 4000
host: localhost
views: views
logLevel: info
ssl: falseRun with CLI overrides:
npx noxt-js --port 8080 --views src/pagesAvailable options
port: HTTP port number (default:3000)host: Hostname or IP (default:0.0.0.0)views: Directory containing.jsxfiles (default:views)logLevel: One oferror,warn,info,debugssl:false(disable SSL)- or object with
certandkeypaths for HTTPS
Context
You can provide shared helpers/utilities to all components via a context.js file (or any path you specify in config). For example:
// context.js
export async function fetchUser(id) {
return db.users.findById(id);
}Then in a page:
export const route = '/user/:id';
export default async function UserPage({ id }, { fetchUser }) {
const user = await fetchUser(id);
return <h1>{user.name}</h1>;
}Pages & Routing
- Any
.jsxfile inviews/is loaded as a component. - If it exports
route, it becomes a page at that route. - Props come from route params, query string, and optional
paramsexport.
Example:
export const route = '/hello/:name';
export default function HelloPage({ name }) {
return <h1>Hello, {name}!</h1>;
}License
LGPL-3.0-or-later
