Examples
The repository includes runnable examples for the main deployment targets.
Minimal JSX app
examples/minimal.tsx shows the shortest path to a JSX app running on Bun.
import { app } from 'jinatra'
import { serve } from 'jinatra/bun'
get('/', () => <h1>Jinatra</h1>)
get('/hello/:name', () => <h1>Hello {params.name}</h1>)
serve(app, { port: 3000 })Node server
examples/node-server.js uses the Node adapter and native static file serving.
EJS views
examples/ejs-server.js is a runnable Node server using native EJS templates from examples/views/. Put templates in views/ and return view() from a route. The template and optional layout names may omit the .ejs suffix:
import { view } from 'jinatra';
import { serve } from 'jinatra/node';
import app from './app.js';
app.get('/', () => view('home', { title: 'Jinatra' }, 'layout'));
serve(app);views/home.ejs:
<h1><%= title %></h1>views/layout.ejs:
<!doctype html>
<html><body><%- body %></body></html>Use serve(app, { views: './templates' }) or new Jinatra({ views: './templates' }) for another template directory.
Cloudflare Worker
examples/cloudflare-worker.js demonstrates a Worker export, cron handling, and Workers Static Assets.
Run the tests
npm testThe test suite exercises routing, request context, middleware, responses, sessions, Cloudflare behavior, JSX SSR, and the Node adapter.