Run a real Nifra app in your browser.
The real @nifrajs/core runs in this tab. Nothing is installed and nothing is sent to a server.
- Write the app
server()declares routes andtdeclares what each one accepts. The code returns the app. - Send requests
Each entry in
requests.jsonbecomes a realRequestpassed toapp.fetch, the same call Bun, Node, and Deno make. - Read the responses
The status and body each request got back, exactly as a client would see them.
Each .get() adds a route. A :name segment arrives on c.params, and a returned object is sent as JSON.
TryChange /hello/world in requests.json to your own name.
Responses
Loading the playground…
What each piece does
server()- Creates an app. Chain
.get,.post,.put,.patch, and.deleteto add routes. c.params- The values of
:namesegments in the route path. c.query, c.body- The query string and the parsed JSON body. Declare a
tschema on the route and they arrive validated and typed. t- The schema builder:
t.object,t.string,t.number,t.boolean,t.array,t.optional, andt.queryfor query strings. Input that fails gets a 422. status(code, body)- Responds with any status code and a JSON body.
.derive(fn)- Runs before every route. Whatever it returns is merged into
c. return app- The playground calls
app.fetchon the app you return. In a project you export it:export default { fetch: app.fetch }. requests.json- An array of
{ method?, path, headers?, body?, label? }, sent in order. Alabelis shown above its response.
Same code, on your machine: bun create nifra my-app