Next app router API method
Answered
Gharial posted this in #help-forum
GharialOP
I am new in next js with past experience in reactjs, what is recommended approach to integrate API In next js as rtk query just for client side but for server side I need to integrate fetch i.e for API call
For that I have to manage integration for both fetch and rtk
For that I have to manage integration for both fetch and rtk
Answered by B33fb0n3
You can create a normal route handler that can then be called from your server and also from your client: https://nextjs.org/docs/app/building-your-application/routing/route-handlers
Keep in mind to build reusable functions, as you don't want to fetch your own api routes serverside
Keep in mind to build reusable functions, as you don't want to fetch your own api routes serverside
4 Replies
@Gharial I am new in next js with past experience in reactjs, what is recommended approach to integrate API In next js as rtk query just for client side but for server side I need to integrate fetch i.e for API call
For that I have to manage integration for both fetch and rtk
You can create a normal route handler that can then be called from your server and also from your client: https://nextjs.org/docs/app/building-your-application/routing/route-handlers
Keep in mind to build reusable functions, as you don't want to fetch your own api routes serverside
Keep in mind to build reusable functions, as you don't want to fetch your own api routes serverside
Answer
@Gharial solved?
GharialOP
Yes 👍