Quickstart
Wire up a complete Nexa-connected Next.js school app in four steps.
Info
This guide is for Next.js 15 App Router. Using a different stack? See Node.js, Vue / Svelte, or the REST API.
Before you start
Make sure you have:
@nexa-ed/nextand@nexa-ed/reactinstalled — see InstallationNEXA_API_KEYandNEXA_WEBHOOK_SECRETin your.env.local— both set to the same API key from the Nexa dashboard (Nexa signs webhooks with your API key)- An auth provider (Clerk or NextAuth) set up in your app
What you'll have at the end: a working teacher dashboard with live OCR progress, structured student records, and a payment widget — wired to the Nexa API in two files.
Step 1 — Create the SDK instance
Create lib/nexa.ts. This is the one place you configure Nexa for your entire app.
Step 2 — Mount the catch-all route
Create a single catch-all route. This one file handles every Nexa endpoint.
That's the entire server-side setup. The route handler covers:
| Method | Path | What it does |
|---|---|---|
GET | /api/nexa/progress/:fileId | Streams real-time OCR progress (SSE) |
GET/POST | /api/nexa/rpc/* | Typed data queries (student records, jobs) |
POST | /api/nexa/webhook | Receives and verifies file completion events |
POST | /api/nexa/prepare | Issues a short-lived upload token (no file body — API key stays server-side) |
GET/POST | /api/nexa/payments/* | Payment initialization, status, config |
POST | /api/nexa/payments/forward | Receives and verifies payment events |
Step 3 — Wrap your app with NexaProvider
Add NexaProvider to your root layout so all React components and hooks can reach the SDK.
NexaProvider defaults basePath to /api/nexa — matching the route you just created. No props needed unless you mounted it at a different path.
Step 4 — Add your first component
Drop ResultsViewerSheet into any server or client page. It renders a full-featured slide-over with a pipeline timeline, student records grid, and stats panel — all wired automatically.
Configure webhook URLs
In the Nexa dashboard → Webhooks, register these URLs so Nexa can call back to your app:
| Event | URL |
|---|---|
file.completed | https://your-domain.com/api/nexa/webhook |
payment.completed | https://your-domain.com/api/nexa/payments/forward |
Student email events (email.created, email.status_changed, email.bulk_completed) aren't handled by the catch-all route — see Webhooks → Email events if you provision student emails.
Use a tool like ngrok to expose localhost during development.
What's next
Now that the integration is live, explore what you can build:
- File Processing — submit PDFs, stream OCR progress, retrieve records
- Payments — initialize fees, verify transactions, handle webhooks
- Student Emails — provision student email accounts across all three tiers
- Domain Setup — verify your domain to unlock Tier 2/3 and your live key
- React Components — upload zone, records table, payment widget, email provisioning UI
- React Hooks — fine-grained control over every feature