End-to-end integrations
Integrate Lumx into a Next.js app
A copy-paste prompt that wires Lumx into a Next.js App Router app — server-only key, route handlers, and the raw-body webhook trap that bites everyone.
// PROMPT
{ "type": "INDIVIDUAL", "name": "William Default", "taxId": "100.100.100-01", "birthDate": "1990-01-01" }
You are a senior full-stack engineer adding Lumx payments to an existing Next.js App Router application. The API is server-side only, so every design decision follows from that.
Ground truth. Read both before writing any code and follow them over any prior knowledge:
1. https://docs.lumx.io/llms.txt — the documentation index. Every page has a .md twin at its own path.
2. https://lumx-docs-public-prod.s3.us-east-1.amazonaws.com/api-production.yaml — the OpenAPI 3.1 spec, for field names, required flags and enums.
1. Put the key somewhere it cannot leak. Read it from a server-only environment variable, never one prefixed for the client, and add the env file to .gitignore. If the repo has a client component importing anything that touches the key, that is the first thing to fix.
2. Build one server-side Lumx module that every route handler shares: base URL from configuration, the bearer header, the Idempotency-Key header, and error parsing that keeps requestId and branches on code.
3. Expose route handlers, not direct calls from components: one to create a customer with POST /customers, one to read status with GET /customers/{id}, one to start a deposit with POST /transactions/on-ramp, and one to read a transaction with GET /transactions/{id}. The browser talks only to these.
4. Handle the webhook in a route handler that reads the raw body. In the App Router that means awaiting request.text() and verifying over that exact string — calling request.json() first re-serializes the payload and every signature check fails with a message that looks like a wrong secret.
5. Render the payment details returned in state.payment on the server and pass only display values to the client. Its shape follows the rail, so take field names from the API reference examples for the rail you use and flag anything you cannot find there.
6. Generate the Idempotency-Key when the user starts a payment, persist it with your own order row, and reuse it if the request is retried. A key minted inside a retry is the same as no key.
7. Add the docs MCP server to the project so schema lookups do not come from memory: claude mcp add --transport http lumx-docs https://docs.lumx.io/mcp
Constraints:
- No Lumx call from a client component, a server action invoked with client-supplied amounts, or a middleware. Amounts and customer ids come from your own server-side state.
- Do not cache a wallet address in the client or the database. The docs do not state that it is permanent; read it when you use it and flag the question.
- Do not state a rate limit. None is published. Handle 429 TOO_MANY_REQUESTS with exponential backoff.
Deliverables:
- The shared server module, plus the four route handlers.
- The webhook route with a raw-body test that fails if someone switches it to request.json().
- A .env.example listing the server-only variables, with no real values.
Tell the agent which Next.js version and whether you are on the App or Pages Router before it starts — the raw-body handling differs and this prompt assumes App Router.
Create the key and the webhook endpoint yourself; the tunnel URL has to exist before the handler can be tested.
Review the client-server boundary by hand at the end. It is the one thing in this prompt where a mistake is invisible until it is public.
Discover how our infrastructure can seamlessly integrate stablecoins into your financial operations quickly, securely, and efficiently.

