How to get Next.js working with Laravel Forge


Next.js is a popular React framework for building server-rendered, static and dynamic web applications.

Laravel Forge is an awesome server deployment tool mostly used for Laravel applications.

The Laravel Forge team has written an article on how to get a Next.js application deployed to Forge. That article is here:

I follow the article but noticed that after each deployment my pages wouldn’t be fresh. Additionally a lot of the interactive Javascript, for example switching to dark mode and some of the mobile menu, didn’t work.

Looking at inspect element it became obvious that something is amiss. This was the output on the console:

Googling ‘buildManifest.js’ and 404 pointed to many results in Google, which made me think something fundamental is amiss. Finally it turns out the deployment advice on the article is this:

cd /home/forge/next-app-static.curved-feather.test
git pull origin $FORGE_SITE_BRANCH
npm install

Whereas in fact I also had to restart the node server, like this:


My conclusion is that after every git push command, the static assets are recompiled and they have new files names. Without refreshing the server those new pages don’t show.

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top