[英]How can I apply Next.js to a React project created with create-react-app?
I'd tried to figure out how to use server side rendering (SSR) on my existing react, and I found Next.js which is a SSR framework for React.我试图弄清楚如何在我现有的 React 上使用服务器端渲染 (SSR),我发现 Next.js 是 React 的 SSR 框架。
Also, there is create-next-app
to easily create Next.js app like CRA.此外,还有
create-next-app
可以轻松创建 Next.js 应用程序,如 CRA。 As I already have my existing React project, I need to make it compatible with Next.js.由于我已经拥有现有的 React 项目,因此我需要使其与 Next.js 兼容。 But, they have quite different project architecutre.
但是,他们有完全不同的项目架构。
I attached two architectures of create-next-app
and create-react-app
each with images below.我附上了
create-next-app
和create-react-app
两个架构,每个架构都带有下面的图片。 As Next requires the folder pages
, I feel like I need to move my components in that folder, but I'm confused about src
and public
folder in create-react-app
.由于 Next 需要文件夹
pages
,我觉得我需要在该文件夹中移动我的组件,但我对create-react-app
src
和public
文件夹感到困惑。
Can anyone help me how can I apply Next.js to an existing React app?任何人都可以帮助我如何将 Next.js 应用于现有的 React 应用程序?
create-next-app创建下一个应用程序
create-react-app创建反应应用程序
You can install Next js by adding 'next' package to your CRA.您可以通过将“next”包添加到 CRA 来安装 Next js。 However, you would have to refractor part of your codebase.
但是,您必须折射部分代码库。 The src folder should contain a subfolder called 'pages', consisting of your paths.
src 文件夹应包含一个名为“pages”的子文件夹,其中包含您的路径。
Visit the Next JS Documentation for more访问Next JS 文档了解更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.