Routes are files
server/routes/client/about.js is /about. [id], [...path], folder middleware and export const GET are built in, and the priority is deterministic.
Node.js framework · Built on Express 5
File-based routes, safe defaults and signed service-to-service calls, built in. Nothing to assemble, nothing to build, no magic to unlearn.
npm install -g white-js@latest
Then create a site: white install example:site my-site
$ white install example:site my-site
✓ Downloading template
✓ Preparing files
✓ Installing dependencies (npm)
$ cd my-site && npm run dev
White.js ready on http://localhost:3000
Why White.js
server/routes/client/about.js is /about. [id], [...path], folder middleware and export const GET are built in, and the priority is deterministic.
Security headers with a per-request CSP nonce, rate limits, a CSRF origin check, signed cookies, request ids and body limits are on before you write a line.
HMAC-signed calls between servers with retries, a circuit breaker, events, discovery and readiness. Switch it on with one mesh setting.
A failed start-up rolls back what it opened. Shutdown drains requests, runs your onClose handlers and exits cleanly. /health and /ready exist from the start.
Live reload in white run dev, generators, white routes, a read-only white doctor, and an installer with live progress.
Declarations for white-js and white-js/test give plain JavaScript completion and checking. defineConfig, defineRoute, definePlugin.
Small surface
// GET /api/items and POST /api/items
export const GET = async (req, res) =>
res.json(await req.ctx.cache.wrap('items', loadItems, '30s'));
export const POST = [
validate({ body: schema }),
(req, res) => res.status(201).json(create(req.valid.body)),
];// GET /blog/:slug -> app/views/post.eta
export default (router, ctx) => {
router.get('/', async (req, res) => {
const post = await ctx.cache.wrap(`post:${req.params.slug}`, () => db.post(req.params.slug), '5m');
res.render('post', { post, title: post.title });
});
};// runs before every route in this folder and below it
import { ForbiddenError } from 'white-js';
export default (router, ctx) => {
router.use((req, res, next) =>
req.session?.admin ? next() : next(new ForbiddenError()));
};import { defineConfig } from 'white-js';
export default defineConfig({
trustProxy: 1,
security: {
cors: { origin: ['https://app.example.com'], credentials: true },
rateLimit: { windowMs: 60_000, limit: 300 },
},
plugins: ['white-plugin-vercel'],
});Services
A site and its API, several back-end services, or separate sites that share data. White.js signs each request, retries what is safe to retry, opens a circuit when a peer is down and carries one request id through every log.
/ready fails while a required peer is downwhite mesh status checks every link from the command line// web/white.config.js
export default {
mesh: {
name: 'web',
peers: {
billing: {
url: process.env.BILLING_URL,
secret: process.env.BILLING_SECRET,
required: true, // /ready fails while billing is down
},
},
},
};
// a route in web: signed, retried, traced by request id
const billing = ctx.mesh.peer('billing');
const invoices = await billing.json('GET', '/api/internal/invoices');Command line
white run devStart with restart on changes and live reload in the browser.
white make route "blog/[slug]"Create a route and its view. Existing files are never overwritten.
white routesList every method, URL and the file it comes from.
white doctorRead-only diagnosis of config, routes, plugins and protocols.
white plugin add <name>Install a plugin and enable it in white.config.js.
white migrate meta@3.0Move to a new protocol generation: backed up, verified, reversible.
Deploy
white run to Vercel in two commands.The Vercel plugin builds a Build Output API bundle: static files on the CDN, your app as one function. No api/ folder to write, no config to copy.
# once per project
white plugin add vercel
# build and deploy a preview
npx white-vercel deploy
# or straight to production
npx white-vercel deploy --prod