One Logo Pool Ball
wwwwwwwwwwwwwwwwwww

one serve

Serve your web apps for production with one serve, after you’ve successfully run one build.

It takes the following arguments:

Terminal window
--host # string, set the hostname to bind to
--port # string, set the port to bind to
--compress # boolean, enable gzip compression, defaults to true
--loadEnv # boolean, whether to load .env files before running
--cluster # enable cluster mode using all CPU cores
--cluster=N # enable cluster mode with N workers

You can also set the port with the ONE_PORT or ONE_FORCE_PORT environment variables. See Environment Variables for details.

One comes with a serve command that is powered by Hono.

If you are only using SPA and SSG routes and aren’t using loaders, you don’t need to use one serve if you don’t want to - you can statically serve the results of dist/client using any server you’d like.

You must run a one build before serve.

Cluster Mode

For production deployments under heavy load, one serve supports cluster mode. This forks multiple Node.js worker processes that share the same port, distributing requests across CPU cores.

Terminal window
one serve --cluster # use all CPU cores
one serve --cluster=4 # use 4 workers
one serve # single process (default)

Each worker handles requests independently. If a worker crashes, it automatically restarts with backoff protection to prevent crash loops.

When to use cluster mode

When single process is better

Performance

At 500 concurrent connections (production-style load test):

Programmatic Usage

You can also run your production server programmatically:

import { serve } from 'one/serve'
await serve()

Which takes options:

type ServeOptions = {
// you can pass in your own Hono server
app?: Hono
host?: string
port?: number
compress?: boolean
/**
* Whether to run the Vite logic to load .env files before running the server
* @default false
*/
loadEnv?: boolean
/**
* Enable cluster mode with multiple worker processes.
* Pass true to use all CPU cores, or a number for specific worker count.
*/
cluster?: boolean | number
}

Edit this page on GitHub.