how to fetch without fetch API in client components in nextjs 13

The beta documents just say that a third party library should be used like SWR, but reviewing the docs for SWR shows that fetch is used beneath it. I'm seeing the same for react query.
6 Replies
Brendonovich
Brendonovich3y ago
What do you want to use instead of fetch?
alan
alanOP3y ago
I was looking for any recommendations. I'd like to use fetch since that's what I used in my network layer of my relay environment, but it looks like the docs are saying that the fetch API is DOA with client components I was seeing a flash of the data retrieved and rendered on the server before fetch would be called on the client side and break the app
alan
alanOP3y ago
https://beta.nextjs.org/docs/data-fetching/fetching#example-fetch-and-use-in-client-components it says client components don't use fetch but then in the same breath presents an example of a client component using fetch
Data Fetching: Fetching | Next.js
Learn how to fetch data in your Next.js application.
Brendonovich
Brendonovich3y ago
Ah yeah, you probs want to use SWR I think fetch doesn't transfer state from server to client properly yet, so it fires multiple times.
alan
alanOP3y ago
I would still use fetch though in there, wouldn't I? It would just be wrapped in SWR I wish the wording was clearer if that were the case
Brendonovich
Brendonovich3y ago
I believe so, not sure on the specifics but it seems that way
Want results from more Discord servers?
Add your server