How to deploy Next.js app without Node.js server?
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
How to Deploy Next.js Apps Without a Dedicated Node.js Server: A Shared Hosting Deep Dive
The desire to deploy modern frameworks like Next.js on shared hosting environments, often utilizing existing PHP infrastructure like Laravel, is a common goal for developers looking to minimize infrastructure complexity and costs. You are running into a fundamental architectural difference between traditional Single Page Applications (SPAs) built with Create React App (CRA) and the server-centric approach of Next.js.
This post will dive deep into why this setup is challenging, explore the viable solution using static export, and outline the best alternatives when true dynamic capabilities are required.
The Node.js Dependency in Next.js
The core confusion stems from how Next.js operates. By default, Next.js relies on a Node.js runtime to perform Server-Side Rendering (SSR), generate data on the fly, and handle routing logic. When you run next build, it compiles code that expects a Node environment to execute these server functions.
The option you mentioned, next export, is the key to solving this deployment hurdle. It instructs Next.js to perform Static Site Generation (SSG), which means it pre-renders all pages into static HTML, CSS, and JavaScript files at build time. This process eliminates the need for a persistent Node.js server at runtime.
The Solution: Leveraging Static Export for Shared Hosting
If your goal is to host the Next.js application alongside a Laravel API on a standard PHP shared hosting environment, the strategy must shift from running a dynamic server to serving static assets directly.
Step 1: Configure Static Generation
Ensure your Next.js project is configured for static export. This process pulls all necessary data and renders the final HTML structure into a publicly accessible folder (usually named out/).
In your next.config.js, ensure you are set up correctly, although the default settings usually support this:
// next.config.js
module.exports = {
output: 'export', // This enables static site generation
};
Run the build command:
npm run build
# This generates the static files in the 'out' directory
Step 2: Hosting Static Files via PHP
Once you have the contents of the out directory (which includes index.html, CSS, and JS bundles), you need a way for your web server (Apache or Nginx, managed by your shared host) to serve these files.
For a simple setup where you want the static site to be accessible directly via a URL, you simply upload the entire contents of the out folder into your public web directory (e.g., public_html). The index.html file becomes the entry point.
Step 3: Integrating with Your Laravel API
Your original idea was to use the Laravel API to serve the content. If you deploy a static site, the flow changes slightly:
- Frontend (Static): The Next.js static files are served directly by the web server.
- Backend (API): Your Laravel application remains separate, handling dynamic data requests (e.g., fetching user profiles or blog posts) via standard REST endpoints.
You can use client-side JavaScript (running in the browser) to make AJAX calls to your Laravel API to fetch dynamic data and inject it into the static HTML structure generated by Next.js. This keeps the heavy lifting of rendering off the shared server while retaining the power of a dedicated backend service, which is often the best practice when utilizing frameworks like those found on the Laravel Company ecosystem for robust data management.
Alternatives When Static Isn't Enough
If your application requires real-time data fetching or complex user sessions that cannot be handled purely client-side (which static sites struggle with), you will inevitably need a server. If shared hosting absolutely prohibits Node.js deployment, consider these alternatives:
- Serverless Functions (Vercel/Netlify): Services like Vercel and Netlify are designed specifically for deploying Next.js apps. They handle the underlying Node.js infrastructure automatically, allowing you to deploy your fully functional SSR application without managing any server configuration—a far superior solution than fighting a shared host environment.
- PHP-Based Frameworks: If sticking strictly to PHP is mandatory, explore frameworks that offer similar rendering capabilities, such as Livewire or Blazor (if using a different stack), which can handle dynamic content generation within the PHP ecosystem, potentially reducing reliance on external Node infrastructure.
Conclusion
Deploying Next.js without a dedicated Node.js server on shared hosting is achievable only by adopting a Static Site Generation (SSG) strategy using next export. This shifts the rendering workload from runtime to build time, allowing your static assets to be served directly by PHP. For truly dynamic applications, however, moving to specialized platforms like Vercel or Netlify offers a more scalable and maintainable path forward than attempting to force a Node environment onto restrictive shared hosting limits.