
No Comments Yet
Be the first to share your thoughts and start the conversation.
Have you noticed what happens when you visit any e-commerce website like Amazon and search for something?
Let’s try it now. Visit the Amazon website, and search for anything that you like. Maybe that MacBook you have been wanting to buy for a long time or that chocolate of yours? Search it
But while searching, keep an eye on “URL”.
Now search.
If you notice carefully enough, you’ll see whatever you typed in the search box will appear in the URL as is.
If I share that URL with you here and if you open it. You should be able to see the same exact results.
This, my friend, is URL as a state management. You won’t see the same effect with other ways of state management.
Lots of websites, not just Amazon, use URLs as state management to keep track of stuff. Even Supabase does it.
For example, I wanted to check how many people bought our Ultimate Next.js course. So, I clicked on a filter, and the web address changed to show that filter.
https://supabase.com/dashboard/project/xxxxxxxxxxxxxxxxxxxx/editor/xxxxx?filter=course_name%3Aeq%3Aultimate-next-js-13-course-ebook&sort=created_at%3Adesc
You see, it's completely legal and actually considered a best practice. By managing state via the URL, you can easily share links, and when someone else opens that link, they'll see the same result as you did. This also helps improve SEO.
💡 How does URL as a state management improve SEO?
When you use unique URLs to represent different states or pages within your website, each URL serves as a distinct entry point for search engines to crawl and index your content.
This means that all the variations of your content, such as different filters, sorting options, or pagination, have their own URLs, making it easier for search engines to discover and rank your pages appropriately.
In simple terms, imagine your website is like a big library, and each URL is like a unique bookshelf. When you organize your books (content) on different bookshelves (URLs), it's easier for people (search engines) to find the specific book (content) they're looking for.
This organization helps improve your website's visibility and ranking in search engine results because search engines can better understand the structure and relevance of your content.
Using unique URLs for different states or pages also makes it easier for users to share specific content and for search engines to understand the context of that content, which ultimately can lead to better search engine rankings for your website.
So is it something new in Next.js?
Not at all. You can do the URL state management in React too.
URL state management is so underrated in the dev field that it took almost a new Next.js release to make us realize how powerful it is. Otherwise, we'd just keep using states all over the place.
Be the first to share your thoughts and start the conversation.
By logging in, you'll unlock full access to this and other free tutorials on JSM Pro.
Why? Logging in lets us personalize your learning experience, track your progress, and keep you in the loop with new workshops, coding tips, and platform updates.
You'll also be the first to know about upcoming launches, events, and exclusive discounts.
No spam—just helpful content to level up your skills.
If that sounds fair, go ahead and log in to continue →
Enter your name and email to get instant access
In this lesson, the presenter discusses the concept of URL state management in the context of e-commerce sites like Amazon and how it can be beneficial for both users and search engines. By reflecting search inputs in the URL, users can share links that lead to the same search results, and it offers an effective way to manage the state of applications.
00:00:02 Have you noticed what happens when you visit any e-commerce site like Amazon and search for something?
00:00:08 Well, try it out.
00:00:10 Visit the Amazon website and search for anything that you like.
00:00:13 Maybe that MacBook you've been waiting to buy for a long time.
00:00:16 But while searching, keep an eye on the URL.
00:00:21 If you've been paying attention, you'll see that whatever you typed in the search bar has also been reflected in the URL bar.
00:00:28 But what does that mean?
00:00:29 Well, first of all, one benefit of this is that if you share that URL with your friend, they should be able to see exactly the same results.
00:00:38 And that, my friend, is URL state management.
00:00:42 You won't see the same effect with other ways of state management.
00:00:45 In React, if you manage the filters or the search through the client side and you pass over the link, it's just not gonna contain that data unless you
00:00:53 somehow put it in the URL.
00:00:55 Lots of websites and not just Amazon use URL state management to keep track of stuff.
00:01:01 Even SuperBase does it.
00:01:03 For example, I wanted to check how many people bought the Ultimate Next.js course, so I clicked on a filter, and the web address changed that filter to
00:01:12 show project, editor, and then filter course name.
00:01:16 As you can see, it's completely legal, it works, and it's actually considered the best practice.
00:01:23 By managing the state via the URL, you can easily share links, and when someone else opens that link, they'll see the same result as you did.
00:01:31 And this also helps to improve the SEO.
00:01:34 How, you might ask?
00:01:35 Well, this is because all of the variations of your content, such as different filters, sorting options, or pagination, have their own URLs,
00:01:44 making it easier for search engines to discover and rank your pages appropriately.
00:01:48 In simple terms, imagine your website is like a big library.
00:01:52 And each URL is like a unique bookshelf.
00:01:55 When you organize your books or the content on different bookshelves or URLs, it's easier for people or search engines to find that specific book or content
00:02:06 they're looking for.
00:02:07 Not only does this improve your website's visibility and ranking, It's also the easiest way to manage content.
00:02:14 So is that something new in Next.js?
00:02:16 Well, not at all.
00:02:18 You can do the same URL management in React, but Next.js just allowed us to realize how powerful it is because it helps us to render things on the server side.