Deno
Deploy a NextRush app to Deno using @nextrush/adapter-deno.
@nextrush/adapter-deno connects a NextRush Application to Deno.serve(). Deno is
secure-by-default — the process has no filesystem, network, or environment access until you
grant it explicitly with --allow-* flags.
Installation
Deno resolves npm packages directly with the npm: specifier, or via an import map:
import { createApp } from 'npm:@nextrush/core';
import { createRouter } from 'npm:@nextrush/router';
import { serve } from 'npm:@nextrush/adapter-deno';{
"imports": {
"@nextrush/core": "npm:@nextrush/core",
"@nextrush/adapter-deno": "npm:@nextrush/adapter-deno",
"@nextrush/router": "npm:@nextrush/router"
}
}Minimal deployment
import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { serve } from '@nextrush/adapter-deno';
const app = createApp();
const router = createRouter();
router.get('/health', (ctx) => ctx.json({ status: 'ok' }));
app.route('/', router);
serve(app, { port: Number(Deno.env.get('PORT') ?? '8080') });deno run --allow-net --allow-env server.tsThe `nextrush` meta package defaults to Node.js
nextrush's createApp/listen re-export @nextrush/adapter-node. For Deno, import
createApp from @nextrush/core directly and call serve() from @nextrush/adapter-deno —
as shown above.
Required permissions
Deno requires explicit flags for every capability the app touches:
Common permission flags
| Property | Type | Description |
|---|---|---|
--allow-net | flag | Required — binds the HTTP server and accepts connections. |
--allow-env | flag | Required if reading `Deno.env.get(...)` for port/config. |
--allow-read | flag | Only if serving static files or reading TLS cert/key from disk. |
# Minimal — server only, no env/file access
deno run --allow-net server.ts
# With environment-driven config
deno run --allow-net --allow-env server.ts
# With TLS certs read from disk
deno run --allow-net --allow-env --allow-read server.tsserve() options that matter in production
ServeOptions (@nextrush/adapter-deno)
| Property | Type | Description |
|---|---|---|
port | number= 8080 | Port to listen on. |
host | string= '0.0.0.0' | Host/interface to bind to. |
timeout | number= 30000 | Request timeout in ms, enforced via `Promise.race` (Deno.serve has no built-in per-request timeout). |
shutdownTimeout | number= 30000 | Grace period to drain in-flight requests during `close()` — guards against `server.shutdown()` hanging on a stalled connection. |
cert? | string | TLS certificate (enables HTTPS with `key`). |
key? | string | TLS private key. |
import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { serve } from '@nextrush/adapter-deno';
const app = createApp();
const router = createRouter();
router.get('/health', (ctx) => ctx.json({ status: 'ok' }));
app.route('/', router);
const server = serve(app, {
port: Number(Deno.env.get('PORT') ?? '8080'),
onListen: ({ port }) => console.log(`listening on ${port}`),
});
Deno.addSignalListener('SIGTERM', async () => {
await server.close(); // drains in-flight requests, then tears down extensions
Deno.exit(0);
});
await server.finished;server.finished resolves when the underlying Deno.serve() instance stops — awaiting it keeps
the process alive until shutdown completes. See Reliability for
the full graceful-shutdown pattern.
HTTPS / TLS
const cert = await Deno.readTextFile('./cert.pem');
const key = await Deno.readTextFile('./key.pem');
serve(app, { port: 443, cert, key });Deno Deploy
Deno Deploy runs a handler function rather than a long-lived
Deno.serve() call you own — use createHandler() and let the platform own the server:
import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { createHandler } from '@nextrush/adapter-deno';
const app = createApp();
const router = createRouter();
router.get('/health', (ctx) => ctx.json({ status: 'ok' }));
app.route('/', router);
Deno.serve(createHandler(app));Requirements
- Deno >= 2.0
Related
- Node.js — the default runtime target
- Docker — a verified, build-tested Dockerfile (Node.js)
- Reliability — graceful shutdown, health checks, timeouts