Examples
Examples
Build complete Nile Js features step by step, with every file, the exact commands and the output you should see
Start from the CLI project and add one feature at a time. Run these commands from the project folder with Bun 1.4.2 or later.
| Example | What you build | Features used |
|---|---|---|
| Tasks API in React | A task list and form in a React component that calls the API through @nilejs/client | Actions, client Results, CORS |
| Protected profile | A JWT-protected profile action and a role-checked audit action | JWT, accessControl, global before hook |
| File upload | A document action that accepts a file with size and type limits | Uploads, structured payload, client upload |
| Realtime order updates | Typed order topics, a protected status action and a socket client | Topics, WebSocket policies, socket client |
| Weekly report | A Monday morning report built by a cron job and delivered through a queue | Cron jobs, queues, lifecycle |
| Rate-limited quote | A public price action that allows a short burst per client | Rate limiting |
Before you start
- Install Bun 1.4.2 or later and check
bun --version. - Create the starter project with
bunx @nilejs/cli new my-app, thencd my-appandbun install. - Keep one terminal running
bun run devwhile you call the server from a second terminal.
Each example says which files to create or replace. Files that are not mentioned stay as the starter generated them. Stop a running server with Ctrl+C before you run a script that starts its own server on port 8000.