如何在Firebase托管上部署next.js应用程序? [英] How to deploy next.js app on Firebase Hosting?

查看:110
本文介绍了如何在Firebase托管上部署next.js应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Firebase托管上部署next.js应用程序.但是我不知道将哪些文件推送到服务器.当我运行npm run build并将构建文件夹推送到firebase时.但出现错误,即找不到index.html文件.

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 folder to firebase. But gives error that No index.html file found.

这是构建文件夹输出的图像.我刚刚创建了一个简单的组件用于测试.

Here is the image of output of build folder. I have just created a simple component for testing purposes.

构建命令的输出

推荐答案

检查优先. 这是next.js在其github存储库中提供的官方示例.

示例背后的想法

目标是使用Firebase托管重写规则将Next.js应用程序托管在Firebase Cloud Functions上,以便从我们的Firebase托管URL提供我们的应用程序.每个单独的页面包都在对Cloud Function的新调用中提供,Cloud Function执行初始服务器渲染.

The goal is to host the Next.js app on Firebase Cloud Functions with Firebase Hosting rewrite rules so our app is served from our Firebase Hosting URL. Each individual page bundle is served in a new call to the Cloud Function which performs the initial server render.

这基于 https://github.com/geovanisouza92/serverless-firebase https://github.com/jthegedus/firebase-functions-next-example 如此处所述.

PS:我知道将链接发布为答案不是最好的方法,但是我的代表力量不足以将其作为评论.

PS : I know posting links as answers is not the best way, but my rep power is not enough to put this as a comment.

更新

我最近发现firebase git repo有一个nextjs示例,请务必检查

I recently found out that firebase git repo has a nextjs example, be sure to check this out too. Path in the repo => firebase/functions-samples/nextjs-with-firebase-hosting

这篇关于如何在Firebase托管上部署next.js应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆