yaba101
yaba10111mo ago

How can I Prefetch on client or server component on App router Nextjs?

how can I pretch data on app router nextjs
1 Reply
yaba101
yaba10111mo ago
what is the equivalent implementation of this in app router? export const getServerSideProps: GetServerSideProps = async (context) => { const { req, res } = context; const ssg = await createSSG({ req, res }); await ssg.teams.get.prefetch(); await ssg.user.get.prefetch(); const slug = TeamRouteQueryType.parse(context.query).team; // pass team into this promise for ssg prefetch of different team-based routes await Promise.allSettled([ ssg.teams.getApiKey.prefetch({ slug: slug, }), ]); return { props: { trpcState: ssg.dehydrate(), }, }; };