How to deploy next.js app on Firebase Hosting?

后端 未结 2 1615
不知归路
不知归路 2021-02-18 14:31

I am trying to deploy next.js app on Firebase hosting. But I don\'t understand which files to push to the server. When I run npm run build and pushed the build fold

2条回答
  •  心在旅途
    2021-02-18 14:47

    On package.json you need to add npm scripts for building and exporting like.

      "scripts": {
        "dev": "next",
        "build": "next build",
        "start": "next start",
        "export": "next export"
      },
    

    And then you can run

    npm run build && npm run export
    

    Next build will build your project for shipping and export will put your files ready for hosting on a static hosting server (like firebase hosting).

    npm run export
    

    will create an out/ directory and place all your files there ready for uploading.

    Note:

    If your app needs to generate dynamic pages at the runtime, you can't deploy it as a static app.

    Read more

提交回复
热议问题