Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with SSR (getServerSideProps) instead of SSG? #23

Closed
noahflk opened this issue Aug 16, 2022 · 3 comments · Fixed by #25
Closed

Usage with SSR (getServerSideProps) instead of SSG? #23

noahflk opened this issue Aug 16, 2022 · 3 comments · Fixed by #25

Comments

@noahflk
Copy link
Contributor

noahflk commented Aug 16, 2022

I can't use getStaticProps because I rely on getServerSideProps on some pages. How can I make my translations available? Is there an equivalent to getLocaleStaticProps() for SSR instead of SSG?

@QuiiBz
Copy link
Owner

QuiiBz commented Aug 17, 2022

That's a good point.

For now, you can load locales client-side without any getStaticProps nor getServerSideProps (see https://github.com/QuiiBz/next-international#load-initial-locales-client-side). Let me see how we can support getServerSideProps, but it should be similar to getStaticProps.

@noahflk
Copy link
Contributor Author

noahflk commented Aug 17, 2022

I think it's mainly a TypeScript issue. If I suppress errors it works just fine, since locals can be read from both getStaticProps and getServerSideProps.

// @ts-ignore
export const getServerSideProps: GetServerSideProps = getLocaleStaticProps((ctx) => {
  // @ts-ignore
  return protectedRoute(ctx);
});

@QuiiBz
Copy link
Owner

QuiiBz commented Aug 17, 2022

Just released version 0.2.0 which includes #25 and #24, feel free to reopen if the issue isn't fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants