[英]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:有两种口味:
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.