πΏ Did you know this about Caching in Next.js?
Hey friend,
ICYMI, I've a Black Friday Sale on until Sunday π£.
You can get 50% OFF using the code 'BLACKFRIDAY' on the below 2 products.
Developer to Leader Program πLearn how to lead a team & build a high-performing team even if you have less experience.
| Engineering Leader's Playbook πLearn how to be successful in your first 90 days and what it takes to become a Leader.
|
β
It has been a fantastic week for me. My YouTube channel π₯ is growing, and I have received great feedback on the βTailwind courseβ and other videos.
βCheck out the content if you want to become a better Frontend Developer!
Brand new course on Freecodecamp β¨
I also launched a FREE course on Becoming a Great Manager on FreeCodeCamp. I have often referred to Freecodecamp over the years, and it feels like a dream come true to see my content published there.
βOur Weekly Snack: Purge Cache in Next.js Server Action πΏ
This week's weekly snack will be on Next.js Server Actions and how to purge cache and redirect the user on the server side.
Server Actions are now in React Canary and ready for frameworks and libraries to adopt! If you want to learn Server Actions in-depth and prefer a video walkthrough, check out this comprehensive video I created.
βBut if not, keep reading more about purging the cache in Next.js and redirecting the user.
But first, What are Server Actions?
Next.js server actions allow you to write backend code directly inside your React components. This eliminates the need to build a separate API endpoint to handle form submissions, data updates, and more.
Key takeaways:
- Server actions let you run code directly on the server without a separate API.
- Great for form handling, database updates, validation, redirects, etc.
- Scales easily alongside your frontend code
createUserAction is a server action where you parse the formData and insert data into the database.
redirect function π
In server actions, you can perform routing, which is quite neat.
Thanks to the redirect function. You can direct a user directly to another path.
But after re-directing, you may not see the latest data.
You can read more here βοΈβ
revalidatePath π
To purge the cache data at that specific route, you need to use revalidatePath now. This is what we did with `/posts`.
Latest Frontend News π€«
Next.js supports Partial Pre-rendering π₯
Next.js Vercel now has a feature that supports partial pre-rendering, which means you can defer rendering certain parts of your page.
This is awesome for speeding up your site's performance! For example, you can now hold off on displaying comments on a blog post until your reader reaches them. By the time they finish reading, voila! The comments will magically appear, all ready for
β οΈ This feature is experimental.
But check out this demo that Guillermo created. It's really cool.
|
A healthy battle between Next.js and Remix π₯
Kent C Dodds shares why he won't use Next.js βοΈ.
Then Lee Robinson adds a very healthy response: Why I'm using Next.js βοΈ.
The Frontend Developers Toolbox π§°
- Auto detect and View Layout shifts in your pages on Vercel. Check here βοΈβ
- βA script βοΈ to add gravity to any site - it's really cool
- A real reason why you are not a Senior Engineer and want to be, view this video βοΈ here.
I would love to hear from you π
I'm on a mission to cook up some fresh, mind-blowing courses, and I want to know from you:
Just hit 'reply' to my email. Your ideas are like gold nuggets; I can't wait to turn them into something extraordinary.
Big thanks for being awesomeπ.
I hope you have a great day!