T
tRPC

❓-help

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

Yyaba10112/4/2023
how can I pretch data on app router nextjs 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(), }, }; };

Looking for more? Join the community!