From the course: React: Software Architecture
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Routing with server-side rendering
From the course: React: Software Architecture
Routing with server-side rendering
- [Instructor] So at this point, we're able to render basic components from our reactApp on our server. So the next thing that we're going to do is render our app component. You may have wondered why we didn't do that at first. And that's because in order for it to work, we have to set up routing on our server for the frontend. Now this is going to look a little strange. What we're going to do is we're going to have to import something called static router from react-router-dom. StaticRouter is basically the server side equivalent of BrowserRouter that we saw on the frontend. So here's what it's going to look like. We're going to say inside our renderTostring, we'll say StaticRouter, and I need to also pass a prop called location, which is going to be equal to request.url, that just lets the static router know what route the user is actually requesting, so it can render it accordingly. And then inside of here, we're…
Contents
-
-
-
-
Server-side rendering basics3m 30s
-
(Locked)
Setting up a simple React app5m 12s
-
(Locked)
Basic React SSR6m 40s
-
(Locked)
Building and rendering an SSR React app2m 52s
-
(Locked)
Routing with server-side rendering7m 2s
-
(Locked)
Styling with server-side rendering7m 52s
-
(Locked)
Server-side rendering caveats2m 7s
-
-
-
-
-
-