Skip to main content

Deploying a Next.js application with ISR support



  • DevRel


    As of today, this is the only solution.
    We are aware this feels hacky and are working on bringing better ways to handle such use-cases.
    If you encounter any issue or limitation with the current setup, let us know – we’ll be happy to help.

  • Daniele Bandirali

    In the Company we are looking for a platform to use NextJS + Drupal.
    The Applications we develop make extensive use of NextJS ISR. For this reason, it is imperative for us that you resolve this issue before migrating our sites to your platform. Are you interested and planned when to solve this problem?

  • Dan Morrison

    The deployment methodology is based around the idea that the code you committed to the repository and built and tested is the exact code that runs in production. Self-modifying code that updates itself on the fly will have a bit of a conflict with that philosophy.
    However, the solution described above has been found to be adequate for many uses, there are a number of static site builders that use that method.

    • Pre-build the generated files in one step,
    • then copy them into the desired location during deploy.

    A number of deployment pipelines are somewhat more intricate than that. See gatsby-strapi eg
    It may be possible to supply a new template example that includes the required additional lines for NextJS ISR in the deploy hook, but that has not been contributed yet.

  • Chris Rhymes

    My issue I am having is that next start is run before the deploy hook runs. This means that the .next directory is out of sync when the server starts as the files are copied over later. How would you resolve that issue? Can you move the next start command into the deploy hook so it runs after the mount is updated?

  • Dan Morrison

    I don’t completely follow what the steps are that you are needing, but you’ve got 3 hooks to work with : build , deploy, and post-deploy.
    In general I wouldn’t think there would be a problem with running a start command in the deploy hook. That’s usually when the app is most “live” anyway, with access to all its mounts and services, so that’s where last minute pre-launch tasks go.

  • DevRel

    thanks my issue has been fixed.

  • Joost van Doremalen

    @alexsunny123 I’m running into the same issue. Could you please show your application yaml file?

    Edit: @dman I think I’ve got a workaround for the issue, here’s the PR:


Please sign in to leave a comment.