#Data fetching pattern with a different backend?
20 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
@vague dust server components are technically what your api routes did in pages
The reason it's recommended is cause it's very easy to use
If you don't want to cache, you can opt out from it easily
why is it preferred in both cases to fetch from server side tho? isnt it an extra layer when you already have a backend server which handles both auth and data?
The whole reason to use next is to fetch on the server
To do so on the client you can just use react.
Your api routes, are also on the server
i tried normal react but i wanted some routing features of nextjs cuz of url rewrites and stuff
i have a plan tho but idk if its a good one. we are using sessions for auth so i could maybe verify the sessions by accessing db directly and then call the fetch for data with some cache args. is this a good practice tho?
in this case i get auth and also could cache data too without compromising auth.
Sure
is it cuz of the cache capability or is there some other reasons too?
It's safe
You can use env vars
Dosent require client to do heavy frtching
Much faster
ok thats one good reason enough to use server side fetching
one more question like would this put a lot of load on server side tho? if im fetching from next server?