Next.js Discord

Discord Forum

Is using an external API as a data source anti-pattern when it comes to server components?

Answered
Satin Angora posted this in #help-forum
Open in Discord
Satin AngoraOP
Been reading up a bunch on how NextJS works and server components more specifically.

Seems like to reap the most benefits and utilize all the caching mechanisms and whatnot, server components should be somewhat directly talking to the database and fetching the data (and/or to a NextJS API which is doing that).

My data source is an external Django API, and I was just wondering if that means this is kind of anti-pattern with regards to how NextJS should work since each server component is basically making a fetch API call to an external API endpoint.
Answered by joulev
no its not an anti pattern. using an external backend is very common
View full answer

7 Replies

no its not an anti pattern. using an external backend is very common
Answer
@joulev no its not an anti pattern. using an external backend is very common
Satin AngoraOP
Interesting, and that's just a simple fetch() call in any server component to my backend and call it a day? Nothing extra I would need to be doing to be leveraging all the benefits of NextJS?
Satin AngoraOP
Yep, just checking if there's anything extra. Last question, and not sure if you can help here, but if this is all hosted on AWS, when it comes to server components and fetch(), these should be utilizing the internal private AWS IP of servers correct? So the API call to the server would actually be pretty fast
yes you can. it's just nodejs, do anything you need to access the data using nodejs. fetching internal urls is fine
Satin AngoraOP
Amazing, thank you