aralroca / next-translate

Next.js plugin + i18n API for Next.js 🌍 - Load page translations and use them in an easy way!
MIT License
2.66k stars 206 forks source link

Server components support (next 12) #725

Closed emmekappa closed 1 year ago

emmekappa commented 3 years ago

Any plan for supporting React Server Components introduced in next12? https://nextjs.org/blog/next-12#react-server-components

aralroca commented 3 years ago

I didn't know that next-translate didn't work in Server Components... I haven't even tried it. So there was no plan because I didn't know it didn't work. What is the error @emmekappa? Thanks!

jasonkarjadi commented 3 years ago

Error: You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps

I tried using next 12 with react 18 beta, chakra-ui, and next-translate the other day, and ran into some problems. I got frustrated with it before testing next-translate without chakra-ui, and revert back to react 17.

next-translate - compiled page: / - locale: en - namespaces: navbar, home - used loader: getStaticProps

I noticed next-translate uses getStaticProps, and wonder if that was causing the issue for me. From what I've read, you cannot use things such as getStaticProps in the server. I don't know well enough about the subject, but thought it might be good to leave a couple of words here.

aralroca commented 1 year ago

Already supported in 2.0 😊