Guides

Next.js + Xano: The Integration Guide, With the Gotchas (2026)

How to connect Next.js to Xano in 2026: three ways to wire them, the one we would pick, the step list, and what breaks in auth, webhooks, sign-up attribution and cost.

Summarize with AI
Octo Agency cover: Next.js + Xano, with a purple hexagon pattern

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

Three ways to connect Next.js to Xano
MethodHow it worksWhere the token livesBest forMain risk
Browser calls with the SDKClient Components call Xano with @xano/js-sdk or fetchlocalStorage by default, or sessionStorage or a script-readable cookiePrototypes, realtime features, apps with little server renderingAny injected script can read the token
Server-side calls from Next.jsServer Components, Server Functions and Route Handlers call Xano with fetchAn HTTP-only cookie set by Next.jsSigned-in B2B products, portals, anything with sensitive recordsEvery Xano request now comes from your host, not the user
Static export on Xano hostingNext.js builds with output: 'export' and Xano serves the filesBrowser storage, as in the first methodSimple tools where one vendor and one bill matter more than server renderingNo 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

  1. 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".
  2. 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.
  3. 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.
  4. Write login and signup as Server Actions. Call Xano, then set the token with cookies().set() and httpOnly: true.
  5. 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.
  6. 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.
  7. Filter by auth.id in every Xano endpoint that returns user data.
  8. Tag public reads with next.tags and add one Route Handler that revalidates tags, protected by a shared secret.
  9. 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

Common failure points and the documented rule behind each
AreaWhat goes wrongThe documented rule
AuthToken readable by any script on the pageThe SDK's default storage is XanoLocalStorage
AuthLogin works, but the cookie is never savedCookies cannot be set during Server Component rendering
AuthUsers signed out without warningTokens expire after the seconds you set; refresh is yours to build
AuthAny signed-in user reads another user's recordXano checks the token, not ownership; filter by auth.id
SecurityAnother site calls your API from a user's browserNew API groups default to wildcard CORS
CachingStale data after an edit in XanoRevalidation runs on the next request; a Route Handler does not refresh an open page
WebhooksPassword hashes sent to a third partyTrigger inputs new and old include Internal columns
WebhooksNo trace of last week's failureAPI and trigger history kept 24 hours; tasks 7 days
LogsTokens and personal data in request logsRequest 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

What a Next.js and Xano app pays for, at list prices
ItemXanoVercel (Next.js hosting)
Entry production planEssential: $85 a month yearly, $99 monthlyPro: $20 a month per developer seat, with $20 of included usage credit
Next tierPro: $224 a month yearly, $249 monthlyEnterprise, quoted
Free tier limit10 requests per 20 seconds, 100,000 recordsHobby: 1M function invocations, 4 hours of Active CPU, 100 GB transfer
RequestsNo rate limit on paid plans$0.60 per 1M function invocations
ComputeFixed by plan; $180 a month CPU and autoscale boost on ProActive CPU from $0.128 an hour; memory from $0.0106 per GB-hour
Data transfer250 GB of file bandwidth on Essential and Pro1 TB included on Pro, then from $0.15 per GB
Seats5 on Essential, 10 on ProOne 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.

Frequently asked questions

How do I connect Next.js to Xano?

Add Xano's prebuilt signup, login and auth/me endpoints, then call them from Next.js. Xano supports its @xano/js-sdk package, plain fetch with an Authorization: Bearer header, or a client generated from its Swagger spec. For a signed-in product we would call Xano from Server Actions and Server Components, keep the token in an HTTP-only cookie, and store the Xano base URL in a non-public environment variable.

Should I store the Xano auth token in localStorage or a cookie?

For a product holding customer data, use an HTTP-only cookie set by Next.js on the server. Xano's JavaScript SDK defaults to localStorage, and its cookie storage option writes a cookie scripts can read, so any injected script could take the token. The Next.js authentication guide recommends HttpOnly, Secure, SameSite, an expiry and a path. Cookies must be set in a Server Function or Route Handler.

Can I host a Next.js app on Xano?

Yes, as a static export. Xano's static hosting runs on every plan including Free, which allows one site without a custom domain, and supports Next.js built with output: 'export'. It builds with Node.js but does not run a server at request time, so there is no server rendering, no Route Handlers and no HTTP-only cookie pattern. For those, host Next.js elsewhere and keep Xano as the API.

How do I refresh Next.js pages when Xano data changes?

Tag the cached fetch calls for public data with next.tags, then add a Route Handler that calls revalidateTag. In Xano, a database trigger on insert, update or delete can call that route with an External API Request and a shared secret. Next.js says a webhook caller should pass { expire: 0 } to expire data immediately. Strip the trigger payload first, because it includes Internal columns.

How much does Next.js plus Xano cost at scale?

Xano Essential is $85 a month billed yearly, with no API rate limit and no usage charges, and Pro is $224. Vercel Pro is $20 per developer seat, then metered: $0.60 per million function invocations and Active CPU from $0.128 an hour. On our arithmetic, 2 million server-rendered page views with two seats come to about $125 a month before memory and transfer, at November 2026 list prices.

Sources

  1. Custom Coded Apps Xano Docs, 2026
  2. Xano JavaScript SDK README Xano on GitHub, 2026
  3. User Auth & Data Xano Docs, 2026
  4. Securing Your App Before Launch Xano Docs, 2026
  5. Webhooks Xano Docs, 2026
  6. Database Triggers Xano Docs, 2026
  7. Request History Xano Docs, 2026
  8. Static Hosting Xano Docs, 2026
  9. Pricing Xano, 2026
  10. Billing Xano Docs, 2026
  11. How to implement authentication in Next.js Next.js, 2026
  12. cookies Next.js, 2026
  13. fetch Next.js, 2026
  14. revalidateTag Next.js, 2026
  15. Pricing Vercel, 2026

Tags

  • Next.js
  • Xano
  • Integrations
  • Web Apps
Mihajlo Stojanovic

Mihajlo Stojanovic

Co-founder, Octo Agency

Mihajlo runs the technical side of Octo Agency: Webflow builds, custom backends and the systems that keep a site editable after launch. He has shipped more than twenty Webflow sites a year as a white-label partner and writes about what survives contact with a real marketing team.

Veljko Nikolic

Reviewed by

Veljko Nikolic

Founder, Octo Agency

Veljko runs the build side of Octo Agency. He has shipped marketing sites for B2B teams in legal tech, health and manufacturing, and writes about what survives contact with a real review cycle.