New product features | The latest in technology | The weekly debugging nightmares & more!
July 25, 2023
Take my knowledge and shove it up your brain...
Have you ever been in a situation where you need some pages to have a specific layout and some other pages to have a different layout?
Or you might want to protect your application except for the login page.
I'm sure you could find some workarounds to achieve that, but they're nowhere as simple as the way we're gonna do it using the new Next js 13 group routes.
So here's how this works:
For each group of files that we want to have its own layout, we're going to place those files inside a separate folder, and the name of that folder will be surrounded by parentheses, this way it doesn't affect our route paths.
For example:
app/(test)/products/page.tsx
is the same as:
app/products/page.tsx
But now inside the (test)
folder, we can have a layout.tsx
file which only affects the files inside of it, so you can have a specific header component for these files or different authentication rules or whatever.
Here's what it would look like:
Metadata guide in Next js 13
Next 13 introduced a new way to optimize your metadata, here's what you need to know
Next js 13 Route handlers explained
Forget the old api routes, this is the way
All you need to know about useOptimistic hook in Next js13
A new experimental feature from Next js 13 that will greatly imporove your UX
Next js 13 server actions introduction
Who needs api endpoints when we have server actions ?