Loading video...
Video Failed to Load
How to refactor an existing client component into a server component? 1. Move the state to the URL 2. Move data fetching to the server 3. Isolate interactivity into a smaller client component
112,401 views • 3 years ago •via X (Twitter)
10 Comments

You are killing it, lot of things I learned seeing your videos, will be nice to have a web page that renders all these tips so I don’t have to bookmark them 😅, anyways awesome content!

Thanks, I am working on the dedicated page. *Also secretly hoping that @X will implement better UI for tweet collections so I don't have to build anything

Now what is missing is adding Suspense to show loading states on the server, or use useTransition (in the Search client component) to show loading state on the client.

It would be cool if we can generate these pages statically

We can. 1. Substitute query params with dynamic routes. So the route looks like this /movies/doctor instead of /movies?search=doctor 2. Pass most popular search requests to generateStaticParams

@asidorenko_ pardon the noob but sincere question, but what is the purpose of doing this? How is the code better in moving to the server?

Good question, nothing noob about it. - Ship less JS to the client (improves time to interactive) - Can use secret keys when fetching data - Less client-side re-rendering - Can pre-generate popular search queries at build time - State in the URL is often better UX

Thanks for creating amazing content!

Make some videos on Next js middlewares.

Do you have any specific cases in mind?
