skip to Main Content

I’m starting to learn React. I read that he has a problem with seo optimization. I want to build a project using react-router-dom Whether it is necessary to use next.js in 2022? or is it possible to build everything using react-router-dom and the site will be seo optimized?
what is the best way for seo optimization? ssr vs spa?. react-router-dom vs nextjs?

2

Answers


  1. react-router-dom is expected to be used in SPAs, what it does is you have a source .html file in which all routes will be rendered depending on the current route user is trying to view.

    You can build a project using react-router-dom and serve it statically, if you try to directly go to a route eg: /dashboard it’ll display nothing or a 404 page. When using SSR you redirect any incoming request to your index.html file to make react-router-dom work

    I suggest to give NextJS a try, it has built-in router support, and can generate static content or serve it dynamically form a server. If you know how to configure route and share data among them it’ll be easier for you to transition : )

    Login or Signup to reply.
  2. Use Next.js, it’s better for SEO than React.js

    Also there is next/router module which you can use to route in Next.js

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search