Node.js Runtime
TriFrost runs seamlessly on Node.js, the worldβs most popular JavaScript runtime.
While not as flashy as Bun or Workerd, Node offers battle-tested stability, a massive ecosystem, and rock-solid performance, a great choice for server-heavy, enterprise-grade applications.
This guide covers key setup notes, compatibility quirks, and best practices when running TriFrost on Node.
Why Node.js?
Node gives you:
- π A massive ecosystem of npm libraries
- π§± Mature platform for production-grade systems
- π§ Fine-grained control over file system, streams, networking
- π§ͺ Great compatibility with testing, observability, and CLI tools
TriFrost integrates smoothly with Node:
- Built-in runtime adapter
- Auto-detection
- Stream-based response model (no polyfills)
Minimum Required Version
We recommend:
- β Node v22+ (ideal)
- π° Node v20+ (minimum supported)
Lower versions may lack support for:
- Native globals used by the TriFrost framework
stream/web
compatibility (used internally by TriFrost)- Performance and diagnostic improvements
Project Setup
TriFrost detects Node automatically, no runtime config needed.
You can scaffold a Node-powered TriFrost project in seconds:
npm create trifrost@latest
Then choose:
- Runtime:
Node
- Optional modules: Cache, RateLimiter, Styling, etc.
Or create it manually:
npm install @trifrost/core
npm install -D typescript
Then in your app:
import {App} from '@trifrost/core';
new App()
.get('/', ctx => ctx.text('Hello from Node!'))
.boot();
And in your package.json
:
{
"scripts": {
"dev": "npm run build && npm run dev:watch",
"dev:watch": "tsc --watch & node --env-file=.env --watch ./dist/index.js",
"build": "rm -rf ./dist && tsc -p ./tsconfig.json",
}
}
π You can use tsc
or tsx
, both are supported. We recommend tsc
for smooth local dev.
π Learn more about the Creation CLI
Node-Specific Details
Automatic detection
TriFrost detects Node automatically, no runtime config needed.
TypeScript & JSX Support
Node does not support .ts
and .tsx
natively but TriFrost handles transpilation cleanly with tsc
, and JSX is supported with the right config.
Your tsconfig.json
should be set up with:
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"jsx": "react-jsx",
"jsxImportSource": "@trifrost/core",
...
}
}
Scripts & Watch Mode
The CLI sets up this in your package.json
:
{
"scripts": {
"dev": "npm run build && npm run dev:watch",
"dev:watch": "tsc --watch & node --env-file=.env --watch ./dist/index.js",
"build": "rm -rf ./dist && tsc -p ./tsconfig.json",
}
}
You get instant reloading with:
npm run dev
Container Support (Optional)
TriFrost also supports Podman for containerized Node development. If enabled during setup, it will:
- Scaffold a
Containerfile
withnode:alpine
base image - Configure
compose.yml
with your app on a custom network
podman-compose up
This is useful if you want consistent environments across dev/prod.
π§ͺ Dev Tips
- Use
.env
files for local config - Add
TRIFROST_DEV=true
in.env
to enable dev-mode tracing
π Also see: Dev Mode | Environment Config
Gotchas & Recommendations
- β Make sure you're on Node v20+, earlier versions may lack needed stability for streaming, file serving, etc.
- π Be mindful of mixing CommonJS and ESM β Node supports both, but mixing them requires care.
- β
Prefer
npm install
for standard workflows. Node doesnβt manage a separate lockfile, yourpackage-lock.json
is used. - π§ͺ You can write tests with
vitest
, which integrates smoothly with Node and supports full ESM compatibility. - β
JSX hydration is fully supported out-of-the-box with TriFrost's
client.css
andclient.script
if configured.
π§ Generated Project Structure
A default Node.js project will include:
/src
βββ index.ts β Entry point
βββ routes/ β Route handlers
βββ components/ β Layouts and JSX
βββ css.ts β Styling system
βββ script.ts β Scripting system
βββ types.ts β Context/Env/Router types
/public
βββ logo.svg
βββ favicon.ico
Containerfile (optional)
compose.yml (optional)
eslint.config.mjs
tsconfig.json
package.json
package-lock.json
.env
.prettierrc
All routes and assets fully scaffolded by the Creation CLI, no config needed.
TLDR
- Node is ideal for stability, ecosystem access, and infrastructure-heavy apps
- TriFrost auto-detects Node, no config needed
- Use
tsc
+node
for local dev and production readiness - JSX and TypeScript fully supported with proper
tsconfig.json
- You can opt into container support if desired