Hasura + Next.js
IntermediateWeb AppInstant GraphQL API over PostgreSQL with Hasura, consumed by Next.js: a data layer without the boilerplate.
Published 27 September 2026
About Hasura + Next.js
Hasura + Next.js eliminates the most tedious part of backend development: writing CRUD endpoints. Hasura is a GraphQL engine that sits in front of PostgreSQL and auto-generates a full GraphQL API (queries, mutations, subscriptions, and aggregations) from your database schema instantly. Next.js consumes this API from React components, getting typed data with a single useQuery hook. TypeScript covers both ends.
Hasura's real power is in what it handles automatically: row-level permissions (defined in the Hasura console using the X-Hasura-User-Id session variable from your JWT), real-time subscriptions over WebSocket, computed fields, relationships between tables, and remote schema stitching for federated GraphQL. You define your PostgreSQL schema, configure permissions, and have a production-ready API without writing a single resolver.
Custom business logic that cannot live in the database goes in Hasura Actions (REST endpoints you implement) or Event Triggers (webhooks fired on data changes). This gives an escape hatch for complex operations like sending emails or charging Stripe. Next.js App Router can use React Server Components to call Hasura server-side for SSR, or Apollo or urql client in the browser for interactive queries.
Key Features
- ✓Hasura auto-generates GraphQL queries, mutations, and subscriptions from PostgreSQL schema
- ✓Row-level permissions defined in Hasura console using JWT claims, with no manual filter code
- ✓Real-time GraphQL subscriptions push data changes to Next.js components over WebSocket
- ✓Hasura Actions provide REST escape hatches for custom business logic
- ✓Event Triggers fire webhooks on INSERT/UPDATE/DELETE for async side effects
- ✓Next.js Server Components can call Hasura server-side for SSR with fresh data
When to Use Hasura + Next.js
- →Data-rich apps where the API layer would otherwise be repetitive CRUD boilerplate
- →Teams that want GraphQL without writing resolvers
- →Multi-tenant SaaS where per-user data isolation must be enforced at the API layer
- →Apps that need real-time data subscriptions alongside standard queries
Pros
- Zero boilerplate API: schema changes in PostgreSQL immediately appear in the GraphQL API
- Row-level permissions in the console replace hundreds of lines of middleware code
- GraphQL subscriptions provide real-time updates without custom WebSocket infrastructure
- Hasura permission model is among the most expressive available for row-level access control
Cons
- Hasura adds an infrastructure component: you need to run and maintain the Hasura engine or use Hasura Cloud
- GraphQL overfetch and N+1 queries are still possible if queries are not carefully designed
- Complex business logic still requires custom Actions or Cloud Functions; Hasura does not replace all backend code
- Teams unfamiliar with GraphQL face a learning curve before becoming productive
Database Options for Hasura + Next.js
The standard choice: a full PostgreSQL instance on a managed host or your own server, with Hasura introspecting its schema to auto-generate the GraphQL API. Full control over configuration and which Postgres extensions Hasura can expose.
Serverless PostgreSQL that scales to zero when idle and branches like Git. Hasura connects the same way regardless of which Postgres it points at, so this swaps the database vendor without touching the generated GraphQL schema.
Serverless PostgreSQL billed per operation. Hasura talks to it over a standard Postgres connection string the same as any other instance; there's no interaction with Prisma's own ORM layer here, since Hasura generates its GraphQL API directly from the database schema.
These are highlighted picks. To see all the tools, check the Databases category.
Hosting Options for Hasura + Next.js
Official Next.js support from the same team that builds the framework, with zero-config deploys straight from a git push and edge/serverless functions handled for you, backed by Vercel's global edge network for CDN delivery. Free Hobby usage is scoped to personal, non-commercial projects; production or client work needs the Pro plan, around $20/mo per seat.
A comparable git-based deploy platform to Vercel, with strong Next.js build support and its own global CDN. The free tier covers a personal or small project; paid plans start at $9/mo (Personal), with Pro at $20/mo once traffic or build usage grows.
A container-based platform where the Next.js app deploys as a persistent service instead of serverless functions, useful for long-lived connections a serverless model handles less gracefully. No free tier: the Hobby plan starts around $5/mo in usage credit.
The same persistent-service model as Railway, with a genuinely free tier for small services and its own CDN layer. Free-tier services spin down after inactivity; always-on pricing starts around $7/mo.
These are highlighted picks. To see all the tools, check the Hosting & Cloud category.
Hasura + Next.js Add-ons
Each addition below extends this stack with a capability the base stack works fine without. None are required: include the ones your product actually needs when building this stack, and skip the rest.
Authentication Add-ons
Add authentication when the app needs user accounts — sign-up, login, and data scoped to a specific user instead of a fully open app.
Clerk handles hosted sign-in/sign-up UI and session management out of the box, with its JWT template feeding directly into Hasura's JWT-based row-level permission system, with no custom auth webhook needed.
A self-hosted, open-source auth library instead of a hosted SaaS that issues its own JWTs that Hasura's permission rules can key off the same way, keeping user data in your own PostgreSQL database and avoiding a per-user pricing tier.
An enterprise-grade identity platform with social logins, SSO, and MFA built in, configurable to emit the custom JWT claims Hasura's permission rules key off of, more setup than Clerk or BetterAuth, worth it once compliance or enterprise-customer requirements enter the picture.
These are highlighted picks. To see all the tools, check the Authentication category.
CI/CD Add-ons
Add CI/CD when you want a dedicated pipeline for running tests, linting, or multi-stage builds before a deploy goes out. Many hosting platforms already redeploy automatically on every push on their own — a CI/CD tool adds the most value on top of that by gating the deploy on a passing test suite, and matters even more when the hosting choice does not auto-deploy at all, such as a self-hosted server.
Runs the test suite and triggers deployments on every push, directly from the same GitHub repo the code already lives in, with no separate CI service to configure.
These are highlighted picks. To see all the tools, check the CI/CD Pipelines category.
Containerization Add-ons
Add containerization when you want the app packaged the same way across local development, staging, and production, or need to deploy somewhere that isn't a managed serverless platform.
These are highlighted picks. To see all the tools, check the Containerization category.
Observability Add-ons
Add observability when you want to catch errors and performance regressions in production before users have to report them.
Error tracking and performance monitoring with a dedicated @sentry/nextjs SDK covering both server components and client-side errors. Open-source with a self-hosted path, alongside its own managed cloud.
A broader observability platform covering APM, infrastructure metrics, and log management in one dashboard, useful once a team is already running other services worth monitoring alongside this app. Managed-only, with pricing that scales by host and usage rather than Sentry's per-error volume.
These are highlighted picks. To see all the tools, check the Infrastructure & APM category.
Email Add-ons
Add email when the app needs to send account verification, password reset, or notification messages.
A transactional email API for account verification, password resets, and notification emails that drops into Next.js Server Actions or Route Handlers with a few lines of code, with a free tier for getting started.
The established high-volume choice, with dedicated IP addresses and deliverability tooling for apps sending at serious scale. No permanent free plan (a 60-day trial, then paid tiers), so it earns its slot when volume and deliverability matter more than upfront cost.
Payments Add-ons
Add payments when the product is ready to charge for subscriptions or one-time purchases.
Adds subscription billing, one-time checkout, and invoicing via Stripe's hosted Checkout or embedded Elements, with Next.js Server Actions or Route Handlers handling webhook verification server-side. The stack works fully without it; add this once the product is ready to charge for something.
Styling Add-ons
Add styling when you want a component or utility-class system to build the UI faster than hand-writing CSS from scratch.
These are highlighted picks. To see all the tools, check the CSS Frameworks category.
Analytics Add-ons
Add analytics when you want to measure traffic, track visitor behavior, or understand how people actually use the product.
An all-in-one product analytics platform: event tracking, session replay, feature flags, and A/B testing in one SDK. The richest feature set if you want more than pageviews.
The industry-standard, free analytics platform, with native Google Ads and Search Console integration. Requires a cookie consent banner in most jurisdictions (GDPR/CCPA), and all data lives on Google's infrastructure, the tradeoff the other three picks were built to avoid.
A lightweight, privacy-first analytics tool with no cookie banner required. A good fit for simple traffic metrics without PostHog's broader feature surface.
These are highlighted picks. To see all the tools, check the Web & Product Analytics category.
Frequently Asked Questions about Hasura + Next.js
How is this different from Next.js + PostgreSQL?
Next.js + PostgreSQL has you writing your own API layer (Server Actions, Route Handlers) by hand. This stack replaces that layer with Hasura's auto-generated GraphQL API: schema changes in Postgres show up in the API immediately, at the cost of learning Hasura's permission and query model instead of writing your own.
Do I still need a REST or custom API alongside Hasura's GraphQL?
Not for standard CRUD and real-time subscriptions; Hasura covers those directly. Custom business logic that doesn't map to a database operation, like sending an email or calling a third-party API, still needs a Hasura Action or a separate Next.js API route, since Hasura only generates what it can derive from the schema.
Can I self-host Hasura instead of using its managed DDN tier?
Yes. The open-source Hasura engine runs anywhere via Docker, pointed at the same PostgreSQL instance. Self-hosting avoids Hasura's managed-tier pricing entirely, at the cost of managing the engine's uptime and upgrades yourself instead of a managed service handling it.
What's the cheapest way to run this stack?
Self-hosted Hasura, self-hosted PostgreSQL, and Vercel or Netlify's free hosting tier together cost nothing beyond wherever you self-host Postgres. Hasura's managed DDN Free tier is also genuinely free for a small project if you'd rather not run the engine yourself.
Stacks Related to Hasura + Next.js
Next.js + PostgreSQL
ProjectNext.js with a PostgreSQL database, an ORM, and authentication: full-stack TypeScript web apps.
Next.js + Payload CMS
ProjectNext.js app with Payload CMS as a code-first, developer-friendly content backend.
Directus + Next.js
ProjectThe open-source backend platform on your own PostgreSQL or MySQL database, rendered by Next.js.
Convex + Next.js
ProjectNext.js with a real-time, authenticated Convex backend: type-safe, subscription-first full-stack.
Scores
Popularity2/5
Hasura has a dedicated but comparatively small user base next to a hand-written REST or tRPC API — genuinely capable for teams that want instant GraphQL, but a specialized choice rather than a mainstream default.
Learning Curve4/5
Next.js itself is approachable, but Hasura adds a genuinely new mental model on top — GraphQL schema design, its permission system built on JWT claims, and reasoning about auto-generated queries instead of hand-written ones. Teams unfamiliar with GraphQL face a real ramp-up before this feels productive.
Flexibility3/5
Hasura auto-generates the CRUD layer from the Postgres schema, which is fast to start with but pushes you toward Hasura's own permission and query patterns. Custom business logic still needs Hasura Actions or separate Cloud Functions, so it's flexible for data access but more constrained for anything beyond it.
Performance4/5
Hasura compiles GraphQL queries directly to SQL, avoiding the N+1 problem a hand-rolled resolver layer often introduces, and Next.js Server Components can call it server-side for fast, fresh-data SSR. Not a 5 only because overfetching is still possible if queries aren't scoped carefully.
Portability3/5
The underlying PostgreSQL data is fully portable, but Hasura's permission rules, Actions, and event triggers are configuration that has no equivalent in a different data layer — migrating off Hasura means rebuilding the API layer by hand, even though the database itself moves freely.
Tools in the Hasura + Next.js Stack
Programming Languages
APIs & Infrastructure
Add-ons (optional — add any, or none)
Authentication
CI/CD
Containerization
Observability
Payments
Styling
Analytics
Hasura + Next.js Pricing
Next.js, TypeScript and PostgreSQL are open-source and free. Hasura's managed DDN tier is free to start, moving to $5/mo (Base) or $30/mo (Advanced) as request volume and features grow; self-hosting the open-source Hasura engine instead avoids that cost entirely, at the price of running it yourself. Hosting on Vercel or Netlify is free to start, with Pro plans around $20/mo.
Next.js and TypeScript are free to use.
DDN Free covers small projects; Base is $5/mo and Advanced is $30/mo as usage and feature needs grow.
Vercel and Netlify have free tiers; Pro plans are about $20/mo for production.
Self-host for free, or use managed Postgres from about $6–15/mo.