Good, until you require certain page parameters that are only accessible at the page level. I've noticed a significant amount of prop drilling with i18n, where language parameters are passed as props, which are necessary for certain queries. For instance, if I have page.tsx => server1.tsx => server2.tsx, I don't believe there's a particularly efficient way to pass the language parameter from page.tsx to server2.tsx. 🤔
Good point, that is indeed a challenging situation! I'm not sure either if there is a efficient way for passing the language parameter down multiple layers. Off the top of my head maybe one way could be to circumvent the prop drilling by setting the language param to cookies and getting it inside the components with cookies from next/headers nextjs.org/docs/app/api-reference/functions/cookies
@@TuomoKankaanpaa works but afaik that also makes component dynamic meaning on demand rendering. Not reallt ideal when you always have some known subset of languages.
I just wanted a simple, lightweight, quick api for the demonstration purposes for this example and decided to go with that :) but you are right, could have just easily do it with Next.js!
Yes, the recommaded way is to fetch data inside every component who needs that data, because if we are using the extend "fetch" the data gonna be cached automatically. Also we can use "'cache" from React if we don't use "fetch"'.
Good, until you require certain page parameters that are only accessible at the page level. I've noticed a significant amount of prop drilling with i18n, where language parameters are passed as props, which are necessary for certain queries. For instance, if I have page.tsx => server1.tsx => server2.tsx, I don't believe there's a particularly efficient way to pass the language parameter from page.tsx to server2.tsx. 🤔
Good point, that is indeed a challenging situation! I'm not sure either if there is a efficient way for passing the language parameter down multiple layers. Off the top of my head maybe one way could be to circumvent the prop drilling by setting the language param to cookies and getting it inside the components with cookies from next/headers nextjs.org/docs/app/api-reference/functions/cookies
@@TuomoKankaanpaa works but afaik that also makes component dynamic meaning on demand rendering. Not reallt ideal when you always have some known subset of languages.
Thank you for the great tips🙏
You are welcome, glad to hear you liked it! I share more tips also on my newsletter bit.ly/free-webdev-advice check it out if at all interested!
i'm confused. why you make your api by express??? Next.js can do it without any library
I just wanted a simple, lightweight, quick api for the demonstration purposes for this example and decided to go with that :) but you are right, could have just easily do it with Next.js!
Yes, the recommaded way is to fetch data inside every component who needs that data, because if we are using the extend "fetch" the data gonna be cached automatically.
Also we can use "'cache" from React if we don't use "fetch"'.
Indeed!
fonts are too small
Sorry about that!
@@TuomoKankaanpaa your content is great keep going bro ❤️
Promo'SM 😑