Deploy

On this page, you'll learn how to deploy your Next.js app and rebuild your site when you update your content.

To deploy your app, follow the instructions for deploying Next.js with your chosen hosting provider:

Handle content changes

Your app needs to be notified or rebuilt when your content changes in Prismic. How you set up your app to handle content changes depends on which router your app uses.

  • Create a webhook

    Add a Prismic webhook to clear the Next.js fetch() cache when your content changes in Prismic.

    Follow the Create a webhook instructions in our webhooks documentation using these values:

    FieldValue
    Name”Display published content”
    URLYour app’s deployed URL + /api/revalidate (e.g https://example.com/api/revalidate).
    TriggersOnly check “A document is published” and “A document is unpublished”.

    You do not need to set up a webhook with your hosting provider.

  • Create a /api/revalidate Route Handler

    Add the following /api/revalidate Route Handler to your Next.js app:

    app/api/revalidate/route.ts
    import { NextResponse } from "next/server";
    import { revalidateTag } from "next/cache";
    
    export async function POST() {
      revalidateTag("prismic"); 
    
      return NextResponse.json({
        revalidated: true,
        now: Date.now(),
      });
    }