API route

Files at src/app/api//route.ts become endpoints at /api/. Each handler is (req: Request) => Response. The page below loads from /api/echo through its loader and renders the result. Try ?demo=querystring, or POST to /api/echo directly with curl.

Loader output (fetched from /api/echo at SSR time)

{
  "method": "GET",
  "path": "/api/echo",
  "query": {
    "demo": "loader"
  },
  "headers": {
    "user-agent": "ureq/2.12.1",
    "content-type": null
  },
  "body": null,
  "receivedAt": "2026-05-01T13:57:28.737Z"
}

Try it from curl

curl https://demo.bext.dev/api/echo?hello=world

            curl -X POST https://demo.bext.dev/api/echo \
                -H 'content-type: application/json' \
            -d '{"foo":"bar"}'

Source

// src/app/api/echo/route.ts
         export async function GET(req: Request) {
                return Response.json({ method: req.method, ... });
    }
    export async function POST(req: Request) {
                const body = await req.text();
                return Response.json({ method: req.method, body, ... });
    }
    // page.tsx
    export async function loader() {
                    const r = await fetch("http://localhost:3032/api/echo?hello=world");
        return await r.json();
    }
    export default function Page({ data }) {
                    return <pre>{JSON.stringify(data, null, 2)}</pre>;
    }