Build for production
px dev is for writing the app. For production, px build prepares everything ahead of time and px serve runs the result.
Add the scripts
{
"name": "my-app",
"type": "module",
"scripts": {
- "dev": "px dev"
+ "dev": "px dev",
+ "build": "px build",
+ "start": "px serve"
},
"dependencies": {
"@palinx/cli": "^0.5.0",
"@palinx/core": "^0.5.0"
},
"devDependencies": {
"@types/bun": "latest"
}
}Build it
Stop bun run dev, then:
bun run build$ px build
◀▶ palinx production build...
Routes: 2 pages, 1 API
Prerendered: 2 pages
Output:
/path/to/my-app/dist/client/index.html
/path/to/my-app/dist/client/.palinx-client-entry-vpwkwbjc.js
/path/to/my-app/dist/server/index.js (1 API route, bundled)
✓ Build complete → /path/to/my-app/dist
Run with: bun /path/to/my-app/dist/server/index.jsYour paths will differ. dist/ holds the prerendered pages, the client bundle, and a self-contained server with your endpoint and service bundled in.
Run it
bun run start$ px serve
[palinx] CSRF is enabled without a secret. Tokens are unsigned, which is vulnerable to subdomain cookie injection. Set security.csrf.secret to a random string (env-sourced) to enable HMAC signing.
◀▶ palinx production server
Local: http://localhost:2500
Network: http://192.168.1.20:2500
API: 1 routes loadedhttp://localhost:2500 is the same app: the menu, the greeting, the counter, and /about and /api/greeting.
How it works
bun run dev |
bun run build, then bun run start |
|
|---|---|---|
| Serves | your src files, compiled on request |
the built dist folder |
| After a change | updates the browser | needs a rebuild |
| Pages | rendered per request | prerendered at build time |
| Unhandled API errors | message in the response | generic 500, details in the server log |
px serve runs dist/server/index.js, and dist runs on its own with Bun: no src, no node_modules. Config from palinx.config.ts is fixed at build time. Deployment covers shipping dist and what's read at startup.
Where to go next
This track covered one path through palinx. The guides go further:
- Routing & layouts: dynamic segments, catch-all and not-found pages,
load(), server-only pages, nested layouts. - Guards: protecting pages, such as behind a login.
- Templates & reactivity: computed values, conditionals and lists, components.
- Services & dependency injection: scopes and services that use other services.
- API endpoints: methods, parameters, request bodies and errors.
- Configuration: ports, security and build options.
- Testing: testing services, components and routes.
For a complete app with auth and a database already wired up, Your first app scaffolds one in a single command.