Next.js Discord

Discord Forum

Understanding route handler

Answered
maslomeister posted this in #help-forum
Open in Discord
Hi there, i have a route handler to get reveiws from external resources

then i use it in my client component like this

 const { data, error, isLoading } = useSWR("/api/reviews/get_reviews", fetcher);


when building my app i noticed that this route handler is built as a static page

â—‹ /api/reviews/get_reviews


Does this mean that all fetch request that are happening inside of this route handler are cached on build and then never refreshed or what?
Answered by B33fb0n3
@maslomeister that means, that the code inside the route handler don't change. Static = no code change. Dynamic = Code change through dynamics parts like parts in the url or params or ...
View full answer

4 Replies

@maslomeister that means, that the code inside the route handler don't change. Static = no code change. Dynamic = Code change through dynamics parts like parts in the url or params or ...
Answer
Even if you have "no code change" you can still get different results. For example when you fetch a external api. The code inside your route handler stays everytime the same, but the results from your api can change