downloading data on the server component vs downloading on the client fetch to api
Unanswered
Gouty oak gall posted this in #help-forum
Gouty oak gallOP
I wonder what will be better:
or
or
on the client component, perform a fetch to the API, where I retrieve and return products
or use the Redux toolkit to fetch from the API?
const ProductsPage = async () => {
const products = await prisma.product.findMany()
<And render client component with props />
or
const ProductsPage = () => {
const products = prisma.product.findMany()
<And render client component with props and use React.use />
or
on the client component, perform a fetch to the API, where I retrieve and return products
or use the Redux toolkit to fetch from the API?
5 Replies
@Gouty oak gall I wonder what will be better:
js
const ProductsPage = async () => {
const products = await prisma.product.findMany()
<And render client component with props />
or
js
const ProductsPage = () => {
const products = prisma.product.findMany()
<And render client component with props and use React.use />
or
on the client component, perform a fetch to the API, where I retrieve and return products
or use the Redux toolkit to fetch from the API?
American Sable
is it just displaying data or do you need dynamic client side updates?
Gouty oak gallOP
dynamic
American Sable
i would say use a server component for the prisma find and all that. then request your api in a client component
then can setup redux toolkit if you need caching and such
Transvaal lion
“I see, so the data retrieval is handled on the server side, and then the client calls it through the API. Got it!”