Prerequisites
- Next.js App Router with TypeScript
- Your application session helper
- A personal Praxa key with
execute:write - Node.js 20 or newer
PRAXA_API_KEY unprefixed: variables beginning with
NEXT_PUBLIC_ are eligible for the browser bundle.
1. Add the server-only client
lib/praxa.server.ts
2. Add the Route Handler
app/api/tasks/route.ts
3. Call it from the client
requestId until the request settles. Reuse it after a
timeout; create a new value only for new logical work.
4. Test the boundary
Mock the upstream request in a Route Handler test and prove:- No session returns
401before the Praxa call. - Invalid input returns
400before the Praxa call. - A valid request forwards one server-owned key and no browser-supplied owner.
- Repeating the same user and request ID emits the same idempotency key.
- Changing either value emits a different idempotency key.
- The response uses
Cache-Control: no-store.
202 response proves admission, not completion.
Troubleshooting
Best practices
- Import
server-onlyin credential-owning modules. - Keep the key unprefixed and scan built client chunks for credential patterns.
- Authenticate and bound the body before calling Praxa.
- Rate-limit per application principal.
- Store the request ID with the draft before the first mutation.
- Add a server-owned run-read route instead of exposing the Praxa key.
- Test Node and edge runtimes separately if your deployment uses both.
Next.js Route Handler reference
Review the current framework conventions in the official Next.js guide.
Optimize for production
- Reuse one configured HTTP or SDK client per process and bound concurrent upstream work.
- Prefer durable admission plus asynchronous readback over holding application requests open.
- Cache only non-sensitive, tenant-scoped reads within their documented freshness window.
- Measure p50/p95 latency, admission-to-terminal time, retries, conflicts, and connection reuse before tuning.
Cleanup and next steps
- Revoke the disposable Praxa key and require a later request to fail.
- Remove synthetic application records and any temporary environment files.
- Cancel or archive unresolved test runs according to the application policy.
- Retain only redacted request, run, and verification identifiers needed for the test record.