# Nextjs github actions deployment to netlify

**URL:** <https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471>\
**Category:** Support\
**Tags:** netlify-cli, deployment, building, nextjs\
**Created:** [July 11, 2023, 3:30pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471 "2023-07-11T15:30:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![software](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/software/32/51401_2.png) [@software](https://answers.netlify.com/u/software)\
**Post date:** [July 11, 2023, 3:30pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471/1 "2023-07-11T15:30:17Z")

</div>

Hello, I would like to deploy a Nextjs website (called enchanting-elf-d42f40 on netlify) using the CLI, through GitHub actions but for now, I’m still getting this error when I want to access it:

> Page Not Found : Looks like you’ve followed a broken link or entered a URL that doesn’t exist on this site.
> 
> ![issue1](https://global.discourse-cdn.com/netlify/original/3X/5/6/56b446dbb3c90ec4a54b0bc229e5eb7e24957333.png)

To do this I’m creating a new site on the netlify UI, linking it to my GitHub repository, but afterward, I’m disabling the builds since I want them to be triggered through the CLI.  
My `netlify.toml` :

```auto
[build]
command = "npm run build"
publish = ".next"

[[plugins]]
package = "@netlify/plugin-nextjs"

```

My `production.yml` :

```auto
name: Build & Deploy to Netlify
on:
push:
branches:
- master
pull_request:
types: [labeled, opened, synchronize, reopened]
jobs:
build-deploy:
if: "!contains(github.event.head_commit.message, 'ci skip')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js version from package.json
uses: actions/setup-node@v3
with:
node-version-file: 'package.json'
- name: Npm install
run: npm ci
- name: Build
run: npm run build
- name: Deploy to Netlify
uses: netlify/actions/cli@master
with:
args: deploy --prod --dir=.next
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_TEST_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

```

No functions are created on the deployment logs on the netlify UI, there are only files that are uploaded. I also tested the —build option for the CLI but it changed nothing.

Example with no CLI deploy, the build is done through netlify UI on another site (everything works):

 ![issue3](https://global.discourse-cdn.com/netlify/original/3X/d/9/d9b149d84260c5e90a9e515f1f0000a63d986f0e.png)

Example with the CLI (code above) :

 ![issue2](https://global.discourse-cdn.com/netlify/original/3X/4/5/4582165459e32d8ad527cc42e0adbda90b2b2923.png)

Any help would be appreciated, thanks in advance.

---

<div class="post-metadata">

**Author:** ![Melvin](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/melvin/32/23606_2.png) [@Melvin](https://answers.netlify.com/u/Melvin)\
**Post date:** [July 11, 2023, 3:53pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471/2 "2023-07-11T15:53:58Z")

</div>

Hi @software,

Thanks for reaching out!

Have you seen this section from the GitHub for the next.js runtime:

> **[GitHub - netlify/next-runtime: The Next.js Runtime allows Next.js to run on...](https://github.com/netlify/next-runtime#deploying)**
>
> The Next.js Runtime allows Next.js to run on Netlify with zero configuration - GitHub - netlify/next-runtime: The Next.js Runtime allows Next.js to run on Netlify with zero configuration

> ## Deploying
> 
> If you build on Netlify, the Next.js Runtime will work with no additional configuration. However if you are building and deploying locally using the Netlify CLI, you must deploy using `netlify deploy --build`. Running the build and deploy commands separately will not work, because the Next.js Runtime will not generate the required configuration.

I also found this blog post that may help:

> **[How to Deploy Next.js to Netlify Manually](https://paulonteri.com/thoughts/how-to/deploy-nextjs-to-netlify-manually)**
>
> How to build and deploy a Next.js app to Netlify manually (via the command line or in CI).

Let us know if you have any questions.

---

<div class="post-metadata">

**Author:** ![smitter](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/smitter/32/23695_2.png) [@smitter](https://answers.netlify.com/u/smitter)\
**Post date:** [July 6, 2024, 1:26pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471/3 "2024-07-06T13:26:54Z")

</div>

I encountered a similar error: where I build my site from github actions successfully, but then I visit the url and I get a blank(all white) page. I followed all the steps outlined by team netlify of [Manually installing NextJs runtime from npm](https://github.com/netlify/next-runtime?tab=readme-ov-file#manually-installing-the-nextjs-runtime)

Having encountered this error, I resoughted to manually run netlify CLI on my local computer to deploy my site. I however ran into this issue shown in below image

 ![netlify-preview-deploy-error](https://global.discourse-cdn.com/netlify/original/3X/9/a/9a0ed5bb55797c1345cb322bd7dcb872a5b913a0.png)

A sample deploy url with a blank white screen is here: [https://668939c395ebaf4fe4699a4a--react-loading-indicators.netlify.app/](https://668939c395ebaf4fe4699a4a--react-loading-indicators.netlify.app/)

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [July 6, 2024, 1:39pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471/4 "2024-07-06T13:39:15Z")

</div>

Based on your site, you don’t seem to be using Next.js, you’re probably using React or at least you were using in the past. You probably have left the index.html in public directory that’s causing this.

---

<div class="post-metadata">

**Author:** ![smitter](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/smitter/32/23695_2.png) [@smitter](https://answers.netlify.com/u/smitter)\
**Post date:** [July 6, 2024, 1:50pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471/5 "2024-07-06T13:50:21Z")

</div>

I successfully moved a react website to nexjs. And now I want to host the nextjs website. My dashboard correctly detects that my site is now a NextJs website though. Here is a peek of a successful deployment after re-running `ntl deploy --build` as shown in my dashboard. But the website is still blank(I mean the draft url)

 ![netlify_success_deploy_log_0n_dash](https://global.discourse-cdn.com/netlify/original/3X/9/a/9a1c3c067b4a590e2fa307968bcb9814e6a3faa1.jpeg)

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [July 6, 2024, 2:29pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471/6 "2024-07-06T14:29:15Z")

</div>

Did you check what I suggested:

> [@hrishikesh](#):
>
> You probably have left the index.html in public directory that’s causing this.

---

<div class="post-metadata">

**Author:** ![smitter](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/smitter/32/23695_2.png) [@smitter](https://answers.netlify.com/u/smitter)\
**Post date:** [July 6, 2024, 9:44pm UTC](https://answers.netlify.com/t/nextjs-github-actions-deployment-to-netlify/96471/7 "2024-07-06T21:44:09Z")

</div>

Yes I did check for the dangling `index.html` in public folder. And after removing it, now i was able to see content of my website rendered. Thanks
