简体   繁体   中英

Next.js vs MERN (or Next.js + MERN)?

I have recently been learning the fundamentals of the MERN stack and Next.js, and feel I understand the basic however I have some questions still...

  1. If I have a complete full stack MERN app (ie node/express backend with a mongodb database serving a React front end), could I theoretically replace that entire app with Next.js? What are the pros/cons/considerations with this idea?

  2. Could I potentially have a Next.js app that connects to my own node/express/mongodb back-end? If so, would this essentially be my Next.js app connecting to my node/express back-end directly in my getStaticProps/getServerSideProps functions with fetch(/or axios) without needing an api defined in the pages/api directory? What are the pros/cons/considerations with this idea?

  3. If I went with #2 approach above (assuming it's a sensible idea), would there essentially be 2 'backend servers' involved in this project? One that is created by Next.js (where all the SSR-ing and SSG-ing is taking place), and the other that is my separate node/express/mongodb app?

  1. Yes, you can replace React with NextJs, and it would be a good choice regarding serverless functions.
  2. You would need to link it in one of the API routes, I'm actually not sure if you can in getStaticProps, you probably can. Don't count on me for it though.
  3. I suppose so, you could have only a NextJs backend and it would work just fine.
  1. Yes, you can move to Next.js in place of React.js some pros are: Next.js aims to have a best-in-class developer experience and many built-in features, such as Next.js is used in tens of thousands of production-facing websites and web applications, including many of the world's largest brands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM