简体   繁体   English

从 create-react-app (CRA) 转换为 CRA + Next.Js 应用

[英]Conversion from an create-react-app (CRA) to CRA + Next.Js app

I have a SPA made with create-react-app and it contains a forum where logged in users can post along with other features.我有一个使用create-react-app的 SPA,它包含一个论坛,登录用户可以在其中发布其他功能。 The forum is simply a component within the app currently.论坛目前只是应用程序中的一个组件。

For SEO purposes I want to make the forum public and like Stack Overflow use dynamic routing for those posts and it should be viewable to anyone searching on Google without having to login.出于 SEO 的目的,我想让论坛公开,并且像Stack Overflow一样对这些帖子使用动态路由,任何在 Google 上搜索而无需登录的人都应该可以看到它。 The user has greater abilities when logged in.用户登录后拥有更大的能力。

So I assume I have to implement server-side rendering on the forum using Next.js .所以我假设我必须使用Next.js在论坛上实现服务器端渲染

The problem is the rest of the code( React + Redux implementation ) needs no changes and converting it to Next.js would be unnecessary.问题是代码的 rest( React + Redux 实现)不需要更改,不需要将其转换为 Next.js。 Is there a way to implement the forum within the CRA?有没有办法在 CRA 内实施论坛?

Yes there is.就在这里。 The official Next.js docs actually offers solutions on how to incrementally adopt Next.js.官方 Next.js 文档实际上提供了有关如何逐步采用 Next.js 的解决方案。

There are two flavors:有两种口味:

  • subpaths子路径
  • rewrites重写

Their documentation explains both in detail: https://nextjs.org/docs/migrating/incremental-adoption他们的文档详细解释了两者: https://nextjs.org/docs/migrating/incremental-adoption

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 反应由 CRA(create-react-app) 创建的 web 总是重定向到 '/' - react web created by CRA(create-react-app) always redirect to '/' 如何在CRA(create-react-app)中对资产进行版本控制? - How to do versioning for assets in a CRA (create-react-app)? Cypress 测试覆盖率(Create-react-app CRA Typescript) - Cypress Test Coverage (Create-react-app CRA Typescript) Netlify 使用 create-react-app (CRA) 网站构建错误 - Netlify build Error using create-react-app (CRA) website 如何在没有 create-react-app 的情况下像在 CRA 中一样配置代理? - How to configure a proxy like in CRA without create-react-app? 如何在 Vercel 上部署的 Next.js (CRA) 应用程序中从浏览器中删除源代码? - How to remove source code from browser in Next.js (CRA) app deployed on Vercel? 在没有 CRA(create-react-app)的情况下从 react 到 express 获取错误 - Error fetch from react to express without CRA(create-react-app) Create-react-app + TypeScript + CSS 模块:自动生成类型定义而不从 CRA 中弹出 - Create-react-app + TypeScript + CSS Modules: Auto-generating type definitions without ejecting from CRA Create-React-App (CRA) 是否与 Express 是 Node 应用程序一样是 Node 应用程序? - Is Create-React-App (CRA) a Node App in the same way that Express is a Node app? 在使用 CRA (create-react-app) 创建的应用程序中,在哪里可以找到 webpack 配置文件 - Where to find webpack config file inside a app created using CRA(create-react-app)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM