Micro SaaS guides

Architecture

Next.js + Expo With One Shared Backend

How to ship a web app and a native mobile app from one codebase: sharing a tRPC backend, types, and auth between Next.js and Expo without a rewrite.

Search intent

Ship web and mobile from one backend

Primary keyword: nextjs expo shared backend

The expensive way to add mobile to your SaaS is a second team, a second API, and a second auth system. The cheap way is one backend that both Next.js and Expo consume — same database, same business logic, same types, two frontends.

Turn the guide into a product

Skip the SaaS plumbing and ship the web + mobile app.

Zero To Shipped gives you the production Next.js app, Expo mobile app, auth, billing, analytics, email, admin, and deploy paths already connected.

One-time payment. Lifetime updates.

One API, typed end to end

With tRPC (or typed REST), your Next.js app and your Expo app import the same router types. A procedure like `events.create` is written once, validated once with Zod, and both clients get full autocomplete and compile-time safety. Change the input schema and both apps fail the build until they're updated — that's the feature.

  • Define procedures once; web and mobile consume the same contract.
  • Zod schemas double as runtime validation and shared types.
  • Business logic lives behind the API, never duplicated per platform.

Auth that works in a browser and a native app

The trap is building web-only auth (cookie sessions) and then fighting it on mobile. Plan for both from day one: token-based auth that the web app can use via cookies and the native app via secure storage, with the same user, session, and role model behind it.

  • JWT or session tokens issued by one auth layer.
  • Expo SecureStore on mobile, httpOnly cookies on web.
  • Same roles and permissions enforced server-side for both clients.

What this buys you commercially

Beyond engineering elegance: you can launch on web, validate, and then ship iOS/Android in days instead of months because the backend is done. App-store presence becomes a marketing channel, not a rewrite. This architecture is exactly what Zero To Shipped ships out of the box — a production Next.js app and an Expo app already wired to the same tRPC backend.

  • Mobile launch becomes a frontend task, not a platform project.
  • Push notifications and native UX without forking your product.
  • One deploy pipeline and one schema migration story.

FAQ

Can Next.js and Expo share the same backend?

Yes. Expose your business logic through tRPC or a typed API from your Next.js app, and have the Expo app consume the same procedures. With shared types and token-based auth, both platforms stay in sync from one codebase.

Should I build web or mobile first for a SaaS?

Usually web first — faster iteration and easier payments. But architect the backend for both from day one so the mobile app is a frontend project later, not a backend rewrite.