I love the way you explained the route handlers. I’ve watched many videos trying to explain what you did in 30+ minutes. I fully understand the process now. Thanks!
Thanks for all your videos! I started my first Next commercial project, thinking something like "I know React and CRA, so let's go for it". I quickly got stuck on APIs, and discovered your channel thanks to this video. I put the project on standby while I watched your entire playlist, which was very well explained in a simple way.
Great content! I just have a question, is it possible to fetch the api without the domain, like fetch('/api/posts'), if not would it be needed to use domain as an env variable in all environments? Is there a best practice for this?
@Code Ryan Why is it needed to fetch it from route handlers first 24:04 before fetching it in posts page? Is it not possible to fetch it directly in posts page without the route handler?
@@coderyan I see, I just want to know when to use the route handlers and when to use in-page fetch. There may be some advantages/disadvantages between the two. Do you know any?
Thanks for detailed explanation. but I have one confusion, what is the need of route handler when we can do the same thing from server components and client components.
Great question. And most of the time, you shouldn’t need to use a route handler. But there are situations where they’re useful. For example, if you update your database in a client component and want to revalidate the cache, you make make an API request to a route handler to revalidate the cache for a certain path
nicely explained. Even to me it made all sense. Just one question. Isn't it better to have the components directory outside of the app router ? since if we have it inside we would effectively create new routes ending up with localhost:3000/components/ or doesn't it make a difference as long as we don't define a route or page file ?
a really useful guide, thanks it would be better if you uploaded the final code to the git repo so that it can be quickly re-read without reviewing the video
@@coderyan Nextjs uses the convention of page.tsx to serve a route, so the same way route handler has a convention of route.ts , page.tsx and route.ts can co-exist on the same level, But Nextjs does not allow at the same level.
This was so helpful. I've really been struggling handlers! Thank you so much. Looking forward to more videos!
Happy it helped!
Subscribed within first 5 minutes. Exactly what i was looking for. Api routes for dummies! Thank you
Happy it helped!
I love the way you explained the route handlers. I’ve watched many videos trying to explain what you did in 30+ minutes. I fully understand the process now. Thanks!
Happy to hear it helped!
Thanks for all your videos! I started my first Next commercial project, thinking something like "I know React and CRA, so let's go for it". I quickly got stuck on APIs, and discovered your channel thanks to this video. I put the project on standby while I watched your entire playlist, which was very well explained in a simple way.
You’re welcome! Happy to hear the videos are helping and best of luck on your project!
I've been waiting so long for this video and my guy just uploaded, great job👍🏻❤️🐐
Thank you!
Great content! I just have a question, is it possible to fetch the api without the domain, like fetch('/api/posts'), if not would it be needed to use domain as an env variable in all environments? Is there a best practice for this?
Incredible as always 🔥 Thank You! 🚀
You’re welcome!
@Code Ryan Why is it needed to fetch it from route handlers first 24:04 before fetching it in posts page? Is it not possible to fetch it directly in posts page without the route handler?
Yeah that’s probably fine. But this video is covering route handlers so just showing how they work
@@coderyan I see, I just want to know when to use the route handlers and when to use in-page fetch. There may be some advantages/disadvantages between the two. Do you know any?
whats the purpose of using useRouter instead of redirect(21:34) on the view post button? Whats the difference? can anyone explain?
Thanks for detailed explanation. but I have one confusion, what is the need of route handler when we can do the same thing from server components and client components.
Great question. And most of the time, you shouldn’t need to use a route handler. But there are situations where they’re useful. For example, if you update your database in a client component and want to revalidate the cache, you make make an API request to a route handler to revalidate the cache for a certain path
I have an question? Since we can get data with fetch method, so why we need route hander ?
to create endpoints so you can create your own resources api.
Would be great if this video had timestamps :)
nicely explained. Even to me it made all sense. Just one question. Isn't it better to have the components directory outside of the app router ? since if we have it inside we would effectively create new routes ending up with localhost:3000/components/ or doesn't it make a difference as long as we don't define a route or page file ?
Thank you! And it doesn’t actually matter. The only time a folder becomes public is when you add a route.js or page.js file within the folder
@@coderyan I see thanks, now I learned even more!
@SuperYoda7 happy to hear it!
a really useful guide, thanks
it would be better if you uploaded the final code to the git repo so that it can be quickly re-read without reviewing the video
Thank you and I appreciate the feedback. In future videos, I'm better about pushing the final code up to Github
can you give me the resource that you use?
Thanks super helpful vid!!
Happy it helps!
🔥🔥🔥🔥
still don't understand the logic for not allow to create route.ts at the same route segment
I’m not entirely sure I understand what you mean, could you maybe rephrase your question?
@@coderyan Nextjs uses the convention of page.tsx to serve a route, so the same way route handler has a convention of route.ts , page.tsx and route.ts can co-exist on the same level, But Nextjs does not allow at the same level.
@@mohanram18 Yep, you're going to have to nest the route.ts in ./api/ or /app/api/...
Thanks
You're welcome
thank you boss! hi beautiful dog, you about to go for a walk!
Haha thank you!