[

Integrate Lumx into a Next.js app

]

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.

  1. 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.

  2. Create the key and the webhook endpoint yourself; the tunnel URL has to exist before the handler can be tested.

  3. 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.

TALK TO OUR TEAM

Ready to transform your business with stablecoins?

Discover how our infrastructure can seamlessly integrate stablecoins into your financial operations quickly, securely, and efficiently.

©2026. All rights reserved.

LUMX SOCIEDADE PRESTADORA DE SERVIÇOS DE ATIVOS VIRTUAIS LTDA., a private legal entity, enrolled with the CNPJ/MF under No. 42.887.120/0001-00 ("Lumx"), acts as a virtual asset service provider and is in the process of adapting to the regulatory regime for Virtual Asset Service Provider Companies (SPSAV), pursuant to Central Bank of Brazil (BCB) Resolution No. 520/2025, currently being subject to the transition regime set forth in Article 88 thereof.


Lumx US OP LLC ("Lumx") is a financial technology and payments infrastructure company. Lumx US OP LLC is a Money Service Business (MSB) registered with the Financial Crimes Enforcement Network (FinCEN) (MSB #31000316459619). Lumx is not a state-licensed money transmitter and does not, in its own capacity, engage in the provision of regulated money transmission services. All such regulated activities are conducted exclusively through, and under the licenses of, duly authorized financial-institution partners.


Lumx is not a bank, financial institution, payment institution, or custodian of client funds. Certain services made available through the Platform may be provided by duly authorized and regulated third-party partners, in accordance with applicable laws and regulations.

Please refer to Lumx’s Terms of Use and Privacy Notice for further information regarding the conditions governing the use of the Platform and the processing of your personal data.