backendBase points at a thin server you run. It does two things: it
holds your secret Meru api-key (never the frontend), and it serves the wallet
actions the app calls. The Meru Node SDK gives you both in a single handler.
Install
Mount the handler
createMeruHandler returns a standard Web Request → Response function, so it drops
into Next.js, Hono, Bun, and Deno. Mount it at the path you use for backendBase
(here /api/meru).
app/api/meru/[...meru]/route.ts (Next.js)
userIdFromMeruToken just reads the user id out of the session token (a JWT whose
sub is customer:<companyId>:<subjectId> — the wallet is keyed on subjectId):
Other frameworks
Because the handler is(Request) => Promise<Response>:
req/res), wrap it with a small Request/Response adapter, or
run it behind an edge/runtime that speaks the Web Request type.
What it serves
Mounted at/api/meru, the handler answers exactly the routes the wallet client
calls — you don’t implement these yourself:
This is the whole backend for a self-custody wallet: one handler, one secret key.
Balances and history that the public API can’t derive for you (if you want them)
are added as optional resolvers on
createMeruHandler — see the Node SDK reference.