Xano's official JavaScript SDK stores the user's auth token in localStorage unless you tell it otherwise (Xano js-sdk README, read 24 November 2026). That default is fine for a prototype and wrong for most signed-in B2B products, because any script on the page can read localStorage. Most of the decisions in a Next.js and Xano build follow from where that token lives.
This guide covers what the pairing is for, the three ways to connect the two, the one we would choose, a step list, what breaks and what it costs at scale. Every limit and price comes from Xano's, Next.js's or Vercel's own documentation and pricing pages, read on 24 November 2026.
What the pairing is for
Next.js renders pages and runs server code. Xano is a hosted backend: a Postgres database, endpoints built as visual function stacks, token-based auth, background tasks and database triggers. Teams pick the pair when the product needs a coded front end but the people changing business logic after launch are not backend developers.
The integration has three jobs. Keep a signed-in user signed in across server-rendered pages. Make sure every endpoint returns only what that user may see. And tell Next.js when data it has cached has changed in Xano.
We covered Xano itself in "Xano in 2026: What It Is, When to Use It, and How It Fits Webflow or Next.js", and its plans in "Xano Pricing 2026". If the backend is undecided, see "Xano vs Supabase in 2026". This page is narrower: how the two connect, and where the connection fails.
The three ways to connect them
| Method | How it works | Where the token lives | Best for | Main risk |
|---|---|---|---|---|
| Browser calls with the SDK | Client Components call Xano with @xano/js-sdk or fetch | localStorage by default, or sessionStorage or a script-readable cookie | Prototypes, realtime features, apps with little server rendering | Any injected script can read the token |
| Server-side calls from Next.js | Server Components, Server Functions and Route Handlers call Xano with fetch | An HTTP-only cookie set by Next.js | Signed-in B2B products, portals, anything with sensitive records | Every Xano request now comes from your host, not the user |
| Static export on Xano hosting | Next.js builds with output: 'export' and Xano serves the files | Browser storage, as in the first method | Simple tools where one vendor and one bill matter more than server rendering | No server rendering, Route Handlers or HTTP-only cookie pattern |
Sources: Xano Custom Coded Apps, Static Hosting and js-sdk README; Next.js authentication guide (read 24 November 2026)
Browser calls with the SDK. You create an XanoClient, post to the login endpoint and call setAuthToken() with the result. The SDK's browser storage options are localStorage, sessionStorage and document.cookie, and none is HTTP-only, because the SDK has to read the token to send it. Xano says it "handles CORS automatically", so this route works on the first try.
Server-side calls from Next.js. Xano endpoints are "standard REST endpoints", so a server-side fetch with a Bearer header is enough. Next.js keeps the token in a cookie the browser cannot read; its authentication guide recommends HttpOnly, Secure, SameSite, an expiry and a path.
Static export on Xano hosting. Xano's static hosting runs on every plan, including Free, which allows one site without a custom domain. It builds with Node.js but "doesn't run a persistent Node.js server at runtime". In practice this is the first method on a different host.
Not a fourth method. Xano suggests giving your Swagger spec to an AI coding assistant. That produces client code, which still runs in one of the three places above.
The route we would use, and why
For a signed-in B2B product we would make server-side calls from Next.js, and keep the browser away from Xano altogether. We build applications in Next.js, so we state that bias plainly. This is the setup we would choose from the documentation, not a client case study.
The reason is where the token lives. Next.js says non-NEXT_PUBLIC_ environment variables are only available on the server, and an HTTP-only cookie keeps the user's token out of reach of client-side JavaScript. Authorisation still belongs in Xano: the security boundary is the endpoint, not the page. Next.js makes the same point about itself, calling Proxy useful for initial checks but saying it "should not be your only line of defense".
We would use the SDK in the browser only for a realtime channel, with a separate short-lived token.
Step list
- Enable auth on the user table in Xano and add the prebuilt signup, login and auth/me endpoints. Set an expiry, in seconds, on the token; refresh tokens are optional and, in Xano's words, "a dance of logic between your backend and frontend".
- Lock the API group. Replace the wildcard CORS default with your production and preview origins, set Swagger to private or disabled, and delete every auto-generated CRUD endpoint the app does not call.
- Add environment variables in Next.js: XANO_BASE_URL and any service keys, without the NEXT_PUBLIC_ prefix. NEXT_PUBLIC_ values are inlined into the browser bundle at build time.
- Write login and signup as Server Actions. Call Xano, then set the token with cookies().set() and httpOnly: true.
- Build a Data Access Layer with the server-only package: one module that reads the cookie, calls Xano and returns only the fields the page needs.
- Add Proxy for redirects only. On Next.js 16 the file is proxy.ts. Redirect when the cookie is missing; leave the real check to the Data Access Layer.
- Filter by auth.id in every Xano endpoint that returns user data.
- Tag public reads with next.tags and add one Route Handler that revalidates tags, protected by a shared secret.
- Point Stripe and other webhooks at Xano, not at Next.js, with signature verification, and only then wire Xano triggers back to the revalidation route.
What breaks: auth, webhooks and attribution
| Area | What goes wrong | The documented rule |
|---|---|---|
| Auth | Token readable by any script on the page | The SDK's default storage is XanoLocalStorage |
| Auth | Login works, but the cookie is never saved | Cookies cannot be set during Server Component rendering |
| Auth | Users signed out without warning | Tokens expire after the seconds you set; refresh is yours to build |
| Auth | Any signed-in user reads another user's record | Xano checks the token, not ownership; filter by auth.id |
| Security | Another site calls your API from a user's browser | New API groups default to wildcard CORS |
| Caching | Stale data after an edit in Xano | Revalidation runs on the next request; a Route Handler does not refresh an open page |
| Webhooks | Password hashes sent to a third party | Trigger inputs new and old include Internal columns |
| Webhooks | No trace of last week's failure | API and trigger history kept 24 hours; tasks 7 days |
| Logs | Tokens and personal data in request logs | Request bodies are stored unless a field is marked Sensitive |
Sources: Xano js-sdk README, User Auth and Data, Database Triggers, Request History and pre-launch checklist; Next.js cookies, fetch and revalidateTag docs (read 24 November 2026)
Auth. The usual failure is a cookie set in the wrong place. A login form posting to a Server Action works; a helper called from a Server Component does not, because "HTTP does not allow setting cookies after streaming starts" (Next.js docs). Swap refresh tokens in Proxy or a Route Handler for the same reason. Xano checks the token, not ownership: its checklist describes the attack where someone registers, takes a token and iterates IDs.
Calls from one address. With server-side calls, Xano sees your host's servers, not the user's browser. If you add rate limits in Xano, we would key them by user ID, because a limit keyed on the connecting address treats every user as one visitor.
Caching. Next.js fetch caching is opt-in, and a cached request matches "on its URL, method, headers, and body". We would cache only public reads, such as a directory, and fetch anything user-specific uncached. A Route Handler calling revalidateTag marks tagged data stale; for a webhook caller the docs say to pass { expire: 0 } to expire it at once.
Webhooks. Xano's guide builds a receiver as a POST endpoint with Get All Raw Input and checks the signature with its hmac_sha256 filters. We would let Xano own the Stripe webhook, because Xano owns the data it changes. To tell Next.js, a database trigger can call your revalidation route. Strip the payload first: new and old in a trigger are "the whole stored record", including Internal columns such as the password hash.
Xano keeps API and trigger history for 24 hours, so a Friday failure is gone by Monday. We would log webhooks to a small table, and mark token and personal fields as Sensitive.
Attribution. By this we mean knowing which campaign produced a sign-up. The UTM parameters land on a Next.js page; the account is created later by a Server Action, so Xano never sees the landing URL. We would read the parameters in Proxy on the first visit, keep them in a first-party cookie, and pass them from the signup Server Action as inputs to Xano's signup endpoint. Add those inputs before the first campaign goes out.
Cost at scale
| Item | Xano | Vercel (Next.js hosting) |
|---|---|---|
| Entry production plan | Essential: $85 a month yearly, $99 monthly | Pro: $20 a month per developer seat, with $20 of included usage credit |
| Next tier | Pro: $224 a month yearly, $249 monthly | Enterprise, quoted |
| Free tier limit | 10 requests per 20 seconds, 100,000 records | Hobby: 1M function invocations, 4 hours of Active CPU, 100 GB transfer |
| Requests | No rate limit on paid plans | $0.60 per 1M function invocations |
| Compute | Fixed by plan; $180 a month CPU and autoscale boost on Pro | Active CPU from $0.128 an hour; memory from $0.0106 per GB-hour |
| Data transfer | 250 GB of file bandwidth on Essential and Pro | 1 TB included on Pro, then from $0.15 per GB |
| Seats | 5 on Essential, 10 on Pro | One paid seat per developer |
Sources: Xano pricing page and billing docs; Vercel pricing page (read 24 November 2026). Vendor list prices.
The two halves bill differently. Xano's billing docs describe a "fixed price model" with no overages or usage charges, so more traffic does not raise the Xano bill until a plan limit or add-on does. Vercel meters, and the server-side route puts a Next.js function in front of every Xano call.
A worked example, using our arithmetic and our assumptions. A portal serving 2 million server-rendered page views a month, each using 50 milliseconds of Active CPU, makes 2 million invocations ($1.20) and about 27.8 hours of Active CPU ($3.56). Add two developer seats ($40) and Xano Essential billed yearly ($85) and the list total is $129.76. Vercel's $20 included credit would cover the $4.76 of metered usage in this example, leaving about $125 a month before memory and transfer, which depend on response size and how long functions wait on Xano.
The first upgrade is rarely traffic. Essential allows 10 background tasks and 5 seats, so scheduled jobs and contractors push a team to Pro first. Free is the trap at the other end: a page calling three endpoints uses a third of the 10-request window.
What this means for a team wiring Next.js to Xano
Keep the token out of the browser: login in a Server Action, an HTTP-only cookie, and a Data Access Layer that calls Xano from the server. Put every ownership check inside Xano endpoints, delete the ghost endpoints, and replace the wildcard CORS default before launch. Let Xano receive webhooks, strip trigger payloads, keep your own log, capture attribution in Proxy, and budget for seats and tasks before traffic. Our web apps service page explains how we would scope an integration like this.


