Next.js Discord

Discord Forum

Is this ok to do on a server function?

Unanswered
Blue-throated Hummingbird posted this in #help-forum
Open in Discord
Avatar
Blue-throated HummingbirdOP
Is the following okay to do on a server function, I am new to nextJS and I'm not entirely sure if I can fetch data like this on a server component
Image

3 Replies

Avatar
joulev
Yes that is completely fine
Avatar
Blue-throated HummingbirdOP
Alright, so if I wanted to I could move all my API routes to server functions inside the components?
Avatar
joulev
That’s precisely what you should do to fetch data, yes