Using CLI
Use the srvx CLI command to easily start a development or production server.
You can run srvx with your preferred runtime without installation:
npx srvx
pnpx srvx
yarn dlx srvx
deno -A npm:srvx
bunx --bun srvx
Usage
srvx - Universal Server.
SERVE MODE
# srvx serve [options]
$ srvx serve --entry ./server.ts # Start development server
$ srvx serve --prod # Start production server
$ srvx serve --port=8080 # Listen on port 8080
$ srvx serve --host=localhost # Bind to localhost only
$ srvx serve --import=jiti/register # Enable [jiti](https://github.com/unjs/jiti) loader
$ srvx serve --tls --cert=cert.pem --key=key.pem # Enable TLS (HTTPS/HTTP2)
FETCH MODE
# srvx fetch|curl [options] [url]
$ srvx fetch # Fetch from default entry
$ srvx fetch /api/users # Fetch a specific URL/path
$ srvx fetch --entry ./server.ts /api/users # Fetch using a specific entry
$ srvx fetch -X POST /api/users # POST request
$ srvx fetch -H "Content-Type: application/json" /api # With headers
$ srvx fetch -d '{"name":"foo"}' /api # With request body
$ srvx fetch -v /api/users # Verbose output (show headers)
$ echo '{"name":"foo"}' | srvx fetch -d @- /api # Body from stdin
COMMON OPTIONS
--entry <file> Server entry file to use
--dir <dir> Working directory for resolving entry file
-h, --help Show this help message
--version Show server and runtime versions
SERVE OPTIONS
-p, --port <port> Port to listen on (default: 3000)
--host <host> Host to bind to (default: all interfaces)
-s, --static <dir> Serve static files from the specified directory (default: public)
--prod Run in production mode (no watch, no debug)
--import <loader> ES module to preload
--tls Enable TLS (HTTPS/HTTP2)
--cert <file> TLS certificate file
--key <file> TLS private key file
FETCH OPTIONS
-X, --request <method> HTTP method (default: GET, or POST if body is provided)
-H, --header <header> Add header (format: "Name: Value", can be used multiple times)
-d, --data <data> Request body (use @- for stdin, @file for file)
-v, --verbose Show request and response headers
ENVIRONMENT
PORT Override port
HOST Override host
NODE_ENV Set to production for production mode.