Fetching information from NextJS backend on NextJS Client Side
Unanswered
Orinoco Crocodile posted this in #help-forum
Orinoco CrocodileOP
Hey guys, probably a common question, yet I couldn't find the answer.
Here's what I need
- A full-stack NextJS app, which has functions for data fetching which can be called on the client-side components
The reason I need to fetch the data on client-side instead of server is because there are component with filters (like date), and each time the filter is set I need to fetch the data dynamically.
Here are a couple ways I've considered, and why I think they aren't the best solution
- API Routes, time consuming to implement (as they would essentially just be a bridge to a server-side function), plus painful to add types and so on.
- Server actions, POST requests which from what I recall don't run in parallel, and generally a POST request shouldn't be used to get data.
Are there any other solutions I could use? API Routes have the benefit of easy authorization (I have session tokens), so something like this but in functions with easy options for types would be very nice, if all of that is even possible.
Here's what I need
- A full-stack NextJS app, which has functions for data fetching which can be called on the client-side components
The reason I need to fetch the data on client-side instead of server is because there are component with filters (like date), and each time the filter is set I need to fetch the data dynamically.
Here are a couple ways I've considered, and why I think they aren't the best solution
- API Routes, time consuming to implement (as they would essentially just be a bridge to a server-side function), plus painful to add types and so on.
- Server actions, POST requests which from what I recall don't run in parallel, and generally a POST request shouldn't be used to get data.
Are there any other solutions I could use? API Routes have the benefit of easy authorization (I have session tokens), so something like this but in functions with easy options for types would be very nice, if all of that is even possible.