nehalist
nehalist
Explore posts from servers
TtRPC
Created by nehalist on 4/16/2023 in #❓-help
Type of createServerSideHelpers?
seems like somewhere in your code you're referencing prisma on the client
6 replies
TtRPC
Created by nehalist on 4/16/2023 in #❓-help
Type of createServerSideHelpers?
Figured it out myself:
export async function createServerSideProps(
ctx: GetServerSidePropsContext,
callback: (
helpers: DecoratedProcedureSSGRecord<AppRouter>
) => Record<string, any>
) {
const helpers = createServerSideHelpers({
router: appRouter,
ctx: {
user: await getServerSession(ctx.req, ctx.res, authOptions),
},
transformer: superjson,
});

const props = await callback(helpers);

return {
props: {
trpcState: helpers.dehydrate(),
...props,
},
};
}
export async function createServerSideProps(
ctx: GetServerSidePropsContext,
callback: (
helpers: DecoratedProcedureSSGRecord<AppRouter>
) => Record<string, any>
) {
const helpers = createServerSideHelpers({
router: appRouter,
ctx: {
user: await getServerSession(ctx.req, ctx.res, authOptions),
},
transformer: superjson,
});

const props = await callback(helpers);

return {
props: {
trpcState: helpers.dehydrate(),
...props,
},
};
}
6 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
all of this feels like a "choose 2: i18n, trpc, seo" situation 😄
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
that's the big disadvantage of doing it this way, but it seems like it's the only thing that works
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
as far as I understand that should certainly fix this, ya, but also means that I cannot use tRPC queries directly within my components anymore and requires some major refactoring on my existing app
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
it's kinda weird that having i18n with tRPC causes such a chain of problems. feels like I'm the only one that wants a multi-language tRPC app? 😄
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
I'm seriously considering switching to using tRPC only within getServerSideProps so that I can disable SSR, but dx suffers a lot imo with this approach
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
but this would hurt seo, or do I miss something?
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
btw thanks for your time helping me
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
if you inspect the source code of this page it only shows the "loading..." dev. if you remove the i18n provider it shows the actual content
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
well, I don't understand anything at all anymore: as soon as I wrap my app in an I18nProvider the dom becomes "Loading..." which comes from tRPC
const hello = trpc.hello.useQuery({text: 'client'});
const t = useI18n();
if (!hello.data) {
return <div>Loading...</div>;
}
return (
<div>
<p>inside i18n provider</p>
<p>trpc: {hello.data.greeting}</p>
<p>i18n: {t('hello')}</p>
</div>
);
const hello = trpc.hello.useQuery({text: 'client'});
const t = useI18n();
if (!hello.data) {
return <div>Loading...</div>;
}
return (
<div>
<p>inside i18n provider</p>
<p>trpc: {hello.data.greeting}</p>
<p>i18n: {t('hello')}</p>
</div>
);
but without the i18n provider everything is fine. hopefully this repo can help: https://github.com/nehalist/trpc-i18n
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
Unfortunately no, but I'll setup a minimal reproduction repo
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
while it seems to work, there's this weird behavior of as soon as I wrap my app in the I18nProvider my dom (ctrl+u) is suddenly empty and it seems SSR becomes completely broken. without the wrapping container all my data is inside the dom
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
Will try asap, thanks
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
Additionally, there's already an issue at your side - seems like you guys can't fix that: https://github.com/trpc/trpc/issues/596
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
I often see SSR simply being turned off - but what's the point of using next.js then? It's just an spa then, or do I miss something?
35 replies
TtRPC
Created by nehalist on 4/14/2023 in #❓-help
Has anyone ever used tRPC (with SSR) and i18n?
35 replies
TtRPC
Created by nehalist on 11/1/2022 in #❓-help
Load data client-side via react-query while using tRPC with SSR
oh, that's interesting. thanks!
11 replies
TtRPC
Created by nehalist on 11/1/2022 in #❓-help
Load data client-side via react-query while using tRPC with SSR
I don't know why but it kinda feels weird to disable it. all examples have it on and not having getServerSideProps (or similar) really makes code a lot easier to follow
11 replies
TtRPC
Created by nehalist on 11/1/2022 in #❓-help
Load data client-side via react-query while using tRPC with SSR
which means I'd have to disable ssr right?
11 replies