Grow your YouTube views, likes and subscribers for free
Get Free YouTube Subscribers, Views and Likes

STOP using useState instead put state in URL (in React u0026 Next.js)

Follow
ByteGrad

Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship).
Add auth to your app FAST: https://bit.ly/3QOe1Bh

NEW React & Next.js Course: https://bytegrad.com/courses/professi...
Professional JavaScript Course: https://bytegrad.com/courses/professi...
Professional CSS Course: https://bytegrad.com/courses/professi...

Discord: all my courses have a private Discord where I actively participate
Email newsletter (BIG update soon): https://email.bytegrad.com

⏱ Timestamps:
0:00 Examples
0:41 Benefits
2:38 Example overview
4:24 useState
6:56 Synchronize URL with useEffect
7:30 History API
7:54 Query string definitions
8:58 Next.js useRouter
10:20 location.search
11:18 Problems with useState approach
11:58 Switch to URL for state
12:26 useSearchParams
13:35 Link component
16:11 Server component (searchParams)
17:13 Caveat 1: replace vs push
17:57 Caveat 2: unknown values
18:18 Caveat 3: no values
18:32 Caveat 4: urlencoded values (URLSearchParams)
20:47 Realworld use cases

#webdevelopment #programming #coding

posted by ezintombizj