Strapi with Next.js and other front ends

A Strapi front-end integration decides how content is fetched, previewed, cached and refreshed after publishing. This page covers the choices, build sequence, effort drivers and checks that keep the site fast and the drafts private.

On this page

Why connecting Strapi with Next.js is harder than the first API call

The hard part of connecting Strapi to a Next.js, Nuxt, Astro or mobile front end is not fetching JSON. It is deciding where each page is rendered, how long its content is cached, and what triggers a refresh when an editor publishes a change. A first request to the REST API takes an afternoon. Getting the rendering, caching and refresh model right for every content type takes most of the project. Strapi 5 shapes that model in three ways: its response format, its draft and published states, and the permissions granted to the public role.

The response format changed from Strapi 4, and the Strapi 5 docs describe a Strapi-Response-Format: v4 header for backward compatibility during migration. Front-end code written against one shape breaks silently against the other, so the team has to fix the format it builds against before writing components. Draft and published states decide what a front end can see. A preview route that reads drafts and a production route that reads only published entries need different tokens, different query parameters and different cache rules. If those are mixed, unpublished content can reach the public site. The public role in the Users and Permissions plugin decides which content types and fields an anonymous visitor can read, so every relation a page pulls in must be checked against it.

Teams usually need this work when they start a new front end, redesign an existing site, move off a template-based site, or add a second channel such as a mobile app or partner feed. The first build often works in development and then shows the problems that matter in production. Pages go stale because the cache is not tied to publish events. Preview leaks because the same route serves draft and published data. Front ends over-fetch because they ask for deep populate trees on every request. Large relational content, such as articles linked to authors, categories, components and media, multiplies response size and query count when the query is not designed for each page.

Before the build starts, the team should list each front-end route, the content it needs, the freshness it requires, and who may see unpublished content. They should also confirm which API style, REST or GraphQL, their developers will maintain, and which Strapi version and hosting model they will run. Those answers determine the rest of the design.

Which Strapi and front-end parts connect, and what each one owns

A Strapi and front-end integration is six parts that pass content and signals to each other. Each part should own one job, so a change in the rendering layer does not force a change in the content model, and a publish event does not depend on a page build finishing.

Content types and components

The content types, components and relations in Strapi define the shape of every entry the front end receives. They own field names, required fields, relations and localization settings. They must not own page layout, navigation order or presentation flags such as colors or spacing, because those change far more often than the content model and belong in the front end. Review the model with the front-end team before building pages, since a renamed field breaks every consumer at once.

Strapi 5 migration docs

REST and GraphQL content API

The content API is the contract between Strapi and every client. It owns response shape, pagination, filtering, populate depth and which fields are exposed. It must not own business logic that belongs in a custom controller or service, and it must not return draft content to public clients. Both REST and GraphQL are included in every self-hosted Strapi plan, so pick the style by query needs and team skill, not by licensing. Confirm the GraphQL plugin status for your Strapi version before committing.

Public and token permissions

Roles, public permissions and API tokens decide what an unauthenticated browser or a build job can read. They own read scope per content type and per token. They must not be relied on as the only control for write actions or for draft content, which should be separated from published content through the preview route. Review public permissions for every new content type, and use read-only tokens for build and revalidation jobs. Authentication for end users is a separate concern handled by the Users and Permissions plugin.

Front-end data layer

The data layer in Next.js, Nuxt, Astro or a mobile app fetches entries, maps them to components and handles errors and empty states. It owns query construction, typing of responses and the translation from Strapi's response format into view models. It must not own content rules such as which entries are visible or what counts as published, because those decisions belong in Strapi. Check which response format the project uses, since Strapi 5 changed it and a v4 header exists only for backward compatibility during migration.

Rendering and caching layer

The rendering layer decides whether a page is built at deploy time, rendered on request or served from a CDN cache, and it owns cache lifetimes and invalidation. It must not hold the only copy of content or treat a cached page as the source of truth. Plan how stale pages are replaced after a publish, and test the path where Strapi is unreachable during a build. Confirm the framework's current caching and revalidation API against the versions your team has pinned.

Webhooks and the preview route

A webhook from Strapi tells the front end that an entry was published, so it can revalidate affected pages. The preview route lets editors view draft content through an authenticated path. The webhook owns the publish signal and must not carry full content payloads that the receiver trusts without checking. The preview route owns draft access and must not be reachable by anonymous visitors. Confirm the webhook events and payload options available in your Strapi version, and test that editors see drafts only after they sign in.

How a published entry reaches a visitor's page

The path starts when an editor saves and publishes an entry in the Strapi admin panel. Strapi then notifies the front end, which revalidates or rebuilds only the affected routes, and the cache or CDN serves the updated page to visitors. A separate preview branch shows drafts: an editor opens a preview route that calls the content API with an authenticated request, so draft content never reaches the public cache. Check each trust boundary, especially where the admin panel, the Strapi API and the front-end server meet, and confirm how your chosen framework receives publish notifications.

Publish flow from the Strapi admin panel to a visitor, with the preview branch.

How preview and cache refresh keep editors and visitors in step

This integration has to solve two timing problems at once. Editors need to see a draft exactly as it will look before anyone publishes it, and visitors need a page to change soon after publishing without the whole site being rebuilt for every edit. The first problem is about access: draft content must reach only authenticated editors. The second is about freshness: published content must reach the public cache on a schedule or trigger that matches how often the content changes. Treat them as separate paths with separate controls, because a shortcut that solves one often exposes the other.

For refresh, the main choices are time-based revalidation, event-driven revalidation from a publish event, and full rebuilds. Time-based revalidation is the simplest to run, but a page can stay stale for up to the length of its interval, and short intervals add origin requests and rendering work even when nothing has changed. Event-driven revalidation sends a request from Strapi's publish or unpublish lifecycle to the front end, which refreshes only the affected paths, so it keeps content fresh with modest compute. Its cost is the webhook plumbing and the mapping from a content entry to the URLs that display it, and it fails silently if the call does not arrive, so it needs a fallback interval. Full rebuilds are predictable but cost build minutes and time for every change, which suits small sites with rare updates and rarely suits large content catalogs.

Which API style, rendering model and refresh method to choose

This table compares the main choices for connecting Strapi to a front end: API style, rendering model, cache refresh, preview routing and token scope. Read each row by asking when the option fits and what it will cost your team to run after launch. The main takeaway is that most of the operational burden comes from refresh and token handling, not from the choice of REST or GraphQL.

DecisionWhen it fitsWhat it costs operationally
REST versus GraphQLREST suits fixed page shapes and simple caching by URL. GraphQL suits front ends that need varied field selections from several content types in one request.GraphQL queries can grow expensive without depth and complexity limits, and responses are harder to cache at the HTTP layer. REST endpoints need more round trips for composed pages.
Static generation versus server rendering versus hybridStatic generation fits content that changes rarely and tolerates a rebuild. Server rendering fits personalized or frequently changing pages. A hybrid mixes both per route.Static builds add rebuild load and a delay before edits appear. Server rendering adds a live dependency on Strapi uptime and response time for every page view.
Event-driven versus time-based cache refreshEvent-driven refresh fits content editors who need edits live quickly. Time-based refresh fits content that can be a few minutes stale.Event-driven refresh needs a Strapi webhook, a secured revalidation endpoint and retry handling. Time-based refresh is simpler but can serve stale content for the full interval.
Dedicated preview route versus shared routeA dedicated preview route fits editors who review drafts before publishing. A shared route fits teams that publish directly and do not need draft views.A dedicated route needs its own draft-aware token or secret, separate access rules and a cache bypass. Shared routes risk drafts leaking to public visitors if flags are misconfigured.
One API token or public role per front end versus shared accessSeparate tokens or roles fit several front ends, such as a website and a mobile app, each with different content scopes.Each token needs rotation and an owner, and each extra front end adds a rotation step. A shared token is simpler to manage but widens the blast radius if it leaks.

How to connect a Next.js front end to Strapi, step by step

This sequence takes a Next.js front end from an agreed content model to a Strapi API that serves published content quickly, previews drafts safely, and refreshes pages when editors publish. Each step ends with a check you can run before moving on.

  1. Finalize the content model for front-end queries

    Start from the page templates and components the front end will render, then map each one to a Strapi content type, component or dynamic zone. Agree field names, relations and required fields with both the content team and the front-end developers, and write down which pages need which relations. This step is owned jointly by the Strapi developer and the front-end lead. It is done when every page template has a written mapping to content types and fields, and the team signs off on it. Check it by walking through one real page template and confirming every element on it has a home in the model.

  2. Configure public and authenticated permissions

    In the Strapi admin panel, set the public role so anonymous requests can read only published content for the types the site displays. Create a separate authenticated role for any content that logged-in users can read, and keep administrative actions out of both. Confirm that API tokens used by the build or the preview service have only the scope they need. Closing check: send an unauthenticated request for a draft entry and confirm it is refused or returns nothing, then send the same request for a published entry and confirm it succeeds. Record the results so a later permission change can be retested.

  3. Define the API shape for population and pagination

    Decide, per page template, which fields the front end selects and how deep relations are populated. Limit population to what the template renders, and use field selection to avoid pulling large text or media fields into list views. Set pagination for every collection that a list page reads, and if you use GraphQL, set query depth and complexity limits so a single request cannot ask for an unbounded tree. Closing check: write the agreed response contract for each template as a sample JSON or GraphQL result and confirm that a live response for each template matches it field for field, with no unexpected nesting or missing relations.

  4. Build the typed data-fetching layer

    Create a single data-access module in the Next.js project that wraps every Strapi call, handles the base URL, token and error responses, and returns typed objects generated from or written to the agreed contract. Keep page components away from raw response shapes. Strapi 5 uses the Document Service API internally and changes the API response format compared with v4, so if this front end was written against v4, check every field access in this layer against the v5 response shape. The Strapi-Response-Format: v4 header exists for backward compatibility during migration, but it is a transitional aid and should not be the long-term design. Closing check: run the type checker and a test that loads each template with a fixture from the agreed contract, and confirm the build fails when a field is renamed in Strapi.

  5. Add the preview route and draft handling

    Build a preview route in Next.js that accepts a secret token from Strapi, verifies it, and fetches draft content for the requested document so editors can see unpublished changes. Preview should use a separate, narrowly scoped credential and should never be reachable without the secret. Make sure the preview mode is off by default and that exiting preview returns the visitor to the published version. Closing check: open the public site without preview and confirm draft text is absent, then open the preview link from an unpublished entry and confirm the draft appears, and that an invalid or missing secret is rejected.

  6. Wire publish events to cache revalidation

    Connect Strapi lifecycle or webhook events for publish, unpublish and update to a Next.js revalidation endpoint. The endpoint should accept only signed or secret-protected requests and revalidate the affected paths or cache tags, including list pages that display the changed item. Decide which events trigger a full revalidation and which trigger targeted ones, and document the mapping. Closing check: publish a change to one entry, then load the affected list page and detail page and confirm both show the new content without a manual rebuild. Also confirm that an unrelated page is not invalidated unnecessarily.

  7. Load-test the most-used pages

    Identify the pages with the highest expected traffic and the list endpoints that feed them, then run a load test against a staging copy of both Strapi and the Next.js application with realistic content volume. Measure response time and error rate at the load you expect, and watch database query counts for population-heavy routes. Fix any route that issues excess queries or returns oversized payments before launch, and rerun the test to confirm the fix. Closing check: the agreed targets for response time and error rate are met on each tested page under the expected load, and the results are written down with the Strapi and Next.js versions used. Confirm the targets with your own performance owner, since they depend on your hosting and traffic.

How the integration differs for Next.js, Nuxt, Astro and mobile apps

Next.js can fetch Strapi content at request time on the server, at build time for static pages, or on a timed or on-demand refresh. The main design concern is deciding, per route, which of these modes serves the content's freshness needs, and keeping Strapi API tokens and draft content on the server side only. The most likely failure is a page that is statically generated once and never refreshed after editors publish, or a preview route that leaks drafts to public visitors.

  • Per-route rendering mode: Decide which routes are server-rendered, statically generated or refreshed on a timer, and record the reason for each.
  • Revalidation trigger: Confirm how the team's Next.js version supports on-demand revalidation and whether a Strapi webhook can call it securely.
  • Preview mode: Separate draft fetching from public fetching, and confirm how the version handles preview cookies and the draft token.
  • Token location: Keep read tokens in server-only environment configuration so they are never bundled for the browser.
  • Response shape: Confirm that the data-fetching code matches the response format of the Strapi version in use, especially after a v4 to v5 move.

Before launch, confirm the exact caching and revalidation behavior of your Next.js version with a test that publishes a change in Strapi and checks what a visitor sees.

What drives effort and cost in a Strapi front-end integration

This table compares the main drivers of build and running effort when Strapi feeds Next.js, Nuxt, Astro or mobile apps. Read each row as a question to settle in the written scope, since the biggest one-time costs come from modeling and testing, while rebuild capacity, token rotation and upgrades recur after launch.

DriverHow it raises effort or costHow to keep it down
Content types and relationsEach type, component and relation needs a model, permissions, seed content and front-end mapping. Deeply nested relations multiply query shapes and test cases.Model only what pages render. Agree the content model in writing before build, and prefer components for repeated blocks over new types.
Number of front ends and channelsEach Next.js site, Nuxt app, Astro site or mobile app needs its own fetch layer, preview setup, token and error handling. Costs add up per channel.Share one typed API client or schema layer across front ends. Confirm in scope which channels launch first and which are deferred.
Page count and update frequencyLarge page counts raise build time for static output. Frequent editor updates need on-demand revalidation or webhooks, which are more work to build and monitor than a fixed rebuild.Use incremental or on-demand rendering for large catalogs. Ask the partner to state the rebuild or revalidation approach and the expected publish-to-live path.
Preview and editorial workflowDraft preview needs authenticated draft fetches, preview routes, and cache bypass. Review workflows and scheduled publishing add states the front end must respect. Audit logs and review workflows are Enterprise features in Strapi's self-hosted plans.Limit preview to the pages editors actually review. Confirm which workflow features the chosen plan includes before designing around them.
REST versus GraphQL complexityGraphQL adds a schema to maintain, query depth and complexity limits to set, and caching that is harder at the HTTP layer. REST needs careful populate and field selection to avoid over-fetching.Pick one API style for the first release unless there is a clear need. Set populate rules and field lists per endpoint, and ask for query performance tests against realistic payloads.
Compliance and access constraintsSeparating draft access from published content, scoping API tokens per front end, and keeping audit records of token use add design and review work. Token rotation and access reviews recur after launch.Use read-only tokens scoped to each front end, store them in the hosting platform's secret manager, and set a rotation schedule. Ask for the access model in writing before build.

Keeping drafts private and public responses limited

A Strapi front end is usually the only thing most visitors ever touch, so the API it calls is the most exposed part of the build. The five risks below come from the way Next.js, Nuxt, Astro and mobile apps fetch content, and each one has a control the team can set and a test that shows the control holds.

Drafts and unpublished fields leaking

The failure is a public endpoint returning draft entries or fields that editors marked as internal, often because a query omits the publication state or a field was granted to the public role by mistake. The control is a permission review of the public role for every content type and field, with draft reads kept on server-side preview routes only. Test it by calling each public read endpoint without a token and checking that unpublished entries and restricted fields are absent from the response, including inside populated relations.

Strapi SSO docs

Over-broad public relation access

A public role may allow a content type while still exposing related entries through populate or nested queries that the team never meant to publish, such as author emails or internal categories. The control is to grant read access to each related type explicitly and to limit populate depth in the front end's query layer. Test it by running the queries the front end actually sends, with populate options included, against an unauthenticated client and comparing results to the content model that the public is supposed to see.

Preview secrets reaching the browser

Preview mode usually needs a secret and an API token that can read drafts. If either is exposed through a public environment variable or a client bundle, anyone can read unpublished content or trigger preview sessions. The control is to keep preview secrets and draft-capable tokens in server-side code only, with no prefix that frameworks expose to the browser. Test it by building the front end, searching the client bundles and page source for the token and secret values, and confirming preview routes reject requests without the signed secret.

Read-only tokens with minimal scope

A single full-access API token shared between the public site, the build and the preview service gives every consumer write and delete rights it does not need. The control is one read-only token for public delivery, separate tokens for each build or webhook job, and no admin credentials in the front end at all. Confirm the token types and their permissions in the Strapi admin before launch. Test it by sending a write request with the public read token and expecting a denial for every content type.

CORS and explicit origins

Browser calls from a single-page app or a mobile web view need an allowed origin list, and a permissive wildcard lets any site call the API from a visitor's browser. The control is an explicit list of production, staging and preview origins, with server-side rendering calls kept off the browser path where possible. Test it by sending requests with an unlisted Origin header and confirming the browser receives no permissive CORS response, then repeating the check for each approved origin.

How to test that content, preview and refresh behave correctly

Testing a Strapi and front-end integration has to prove two things: the right content reaches the right visitor, and the system fails safely when something is wrong. Start with contract tests for every endpoint the front end calls, whether REST or GraphQL. Each test should assert the response shape, the fields the page template reads, populated relations and pagination. Run these against the Strapi version and API response format your project actually uses, because a change to the response format or to populate behavior will break a page long before it breaks the database. Keep a fixture of the expected responses in version control so that a diff is visible in review.

Next, run permission tests as an anonymous visitor. Use a request with no token and confirm that draft entries, unpublished relations and private fields never appear in public responses. Then repeat the check with the API token the front end uses at build time, since that token's scope is often wider than a public visitor's. Preview needs its own cases: call the preview route with a missing, invalid and expired secret, and confirm that each request is rejected without revealing draft content or error detail. A failing preview test usually means the design has drawn the trust boundary in the wrong place, so move the check into the server route instead of the page component.

Then measure publish-to-visible time. Publish a test entry in Strapi, record the timestamp, and poll the affected live page until the new content appears. Repeat the test for a direct publish, a scheduled publish and a change to a related entry, since each path can trigger revalidation differently. If the result is slower than your content team can accept, check whether the webhook fired, whether the revalidation call succeeded, and whether a CDN or framework cache sits between the two. Finally, run a load test on the most-visited routes with caching enabled and again with it disabled. Compare latency and the number of requests that reach Strapi. If the uncached run overloads the CMS, the cache is carrying load the origin cannot handle without it, and you need to plan capacity and cache keys before launch. Confirm the exact test tooling and thresholds with your own team, because no figures are set here.

What buyers ask before hiring help for this integration

What drives the cost and effort of connecting Strapi to a Next.js or other front end?

The main drivers are how many content types and relations the front end reads, how many distinct page templates need data, whether preview and draft content are required, and how caching and revalidation are handled. Each added template, locale or preview path adds design, build and test work on both sides. Cost is mostly people time, since a Strapi license is not needed for REST or GraphQL access: the Community Edition is free and includes both APIs, according to Strapi's self-hosted pricing page. Ask any partner for a quote that lists these components separately: API design, front-end data layer, preview, caching, and testing.

Can our own team build a Strapi and front-end integration without a partner?

Yes, a team with experience in both a modern front-end framework and Strapi can build the integration itself. The work is mostly well-documented, but the hard parts are API response shape, preview with draft content, cache invalidation after publish, and permissions for public versus authenticated reads. Confirm that at least one engineer has built this pattern before and that someone owns the decisions on caching and access. A partner is most useful when the team lacks that experience or needs the work finished on a fixed timeline.

What does our organization need to provide for the integration work?

You need content owners who can review the content model and sample entries, a staging environment with a copy of production-like content, and access to the Strapi admin panel and the front-end repository. Decision makers must settle who can see draft content in preview, how long pages may be cached, and which events trigger revalidation after a publish. Also confirm who owns the API tokens and environment variables for each environment. Missing decisions on these points are the most common cause of rework late in the project.

How long does a Strapi front-end integration usually take?

Duration depends on the number of content types, page templates, locales and preview requirements, and on how quickly content owners review the model. A single site with a small set of content types is much shorter to integrate than a multi-brand site with several front ends and mobile apps. Ask for a timeline in the written scope that is tied to named milestones, such as content model sign-off, a working staging preview, and a production cutover. Confirm each milestone with the partner before work starts.

Should we use REST or GraphQL to connect Strapi to our front end?

REST is usually simpler to cache at the CDN and easier for most teams to debug, while GraphQL lets the front end request exactly the fields and relations a page needs in one call. Strapi 5 supports both REST and GraphQL on all self-hosted plans, so the choice is about your team and your pages, not licensing. Consider how many relations each page loads, how your CDN caches responses, and whether mobile apps need smaller payloads. Confirm your choice by building one representative page in each style on staging before committing.

Will the integration work carry over when we upgrade to Strapi 5?

Parts of it will carry over, but response format and API changes matter. Strapi 5 replaces the Entity Service API with the Document Service API and changes the API response format, and a Strapi-Response-Format: v4 header is available for backward compatibility during migration. If you are on Strapi 4, plan for the front-end data layer to be updated during the v4 to v5 move, and test every page template on staging. Confirm the current end-of-life dates and migration steps in Strapi's migration documentation before you plan the upgrade.

What should a written scope for this integration include?

A written scope should name the front ends, the content types and relations each page reads, the preview and draft rules, the caching and revalidation triggers, and the API style. It should also list the environments, the access and token model, the testing approach for each page template, and the handover documents. Ask for deliverables that the team can inspect, such as a documented API contract, a runbook for cache purges, and a list of open decisions with owners. Confirm which items are one-time work and which are ongoing support before you sign.

How DeployOpen scopes, builds and hands over this integration

DeployOpen plans and builds the connection between Strapi and your front end inside your own infrastructure, with the content model, API design and caching rules agreed in writing first. Engagements are fixed-scope, so the deliverables, the front-end targets and the handover items are settled before implementation starts.

How we scope

  • Inventory the front ends in scope, such as Next.js, Nuxt, Astro or a mobile app, and the content each one renders.
  • Decide REST or GraphQL per consumer, with the endpoints, population depth and fields each page needs written down.
  • Agree preview, caching and revalidation behavior, including which content changes must appear within a defined window.

How we build

  • Build the content types, public and authenticated permissions, and API tokens the front end will use, with least-privilege access.
  • Implement the fetching layer, preview routes and revalidation webhooks in the front-end codebase, tested against staging content.
  • Verify caching behavior, CORS settings and response payload sizes against the requirements set during scoping.

How we hand over

  • Deliver the written scope, API reference, environment variable inventory and a list of content model decisions.
  • Document the preview and revalidation flow, including how editors trigger it and how engineers troubleshoot a stale page.
  • Walk your engineering and content teams through the integration and record open items in the agreed handover file.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Retainers can cover Strapi minor releases, front-end framework upgrades and changes to the API contract as pages evolve.
  • Confirm with DeployOpen during quoting which support hours, response paths and upgrade windows the retainer includes.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.