Nextjs Github Pages screenshot

Nextjs Github Pages

Author Avatar Theme by Gregrickaby
Updated: 12 Jan 2026
557 Stars

Deploy a Next.js app to GitHub Pages via GitHub Actions

Categories

Overview

Deploying a Next.js application to GitHub Pages can seem daunting, but the process becomes straightforward when using GitHub Actions. This configuration not only allows for easy deployment each time you push to the main branch, but it also ensures that your static pages are served efficiently. Keep in mind, though, that GitHub Pages isn’t a Node.js server, meaning any dynamic logic that can’t be precomputed won’t be supported.

By following a few essential steps, you can successfully set up your Next.js project for deployment on GitHub Pages, ensuring that your app is available to users with minimal hassle. Whether you’re a seasoned developer or a newcomer, this outline will guide you through the necessary configurations for a smooth setup.

Features

  • Static Export Configuration: Modify the next.config.ts to enable static exports, essential for GitHub Pages deployment.
  • Custom .nojekyll File: Include a .nojekyll file in your public directory to prevent GitHub Pages from generating Jekyll sites.
  • Base Path Addition: Update the src prop in your page.tsx file to include your GitHub repository slug, ensuring images load correctly.
  • Automated GitHub Actions: Create a workflow in .github/workflows/deploy.yml that automatically builds and deploys your app when changes are pushed to the main branch.
  • GitHub Pages Settings: Easily enable GitHub Pages through your repository’s Settings tab, selecting GitHub Actions as the source for deployment.
  • Quick Deployment: After committing your changes and pushing to GitHub, your site will be live on GitHub Pages in just a few minutes.