next-intl
next-intl copied to clipboard
docs: Pages Router API routes
This pull request adds documentation on how to use translations on the server (API routes) in the pages router.
It is not obvious from current documentation that getTranslations
cannot be called from API routes and the error thrown ('getTranslations' is not supported in Client Components
) does not indicate any solution, so this section is intended to (partially) close that gap.
I'm unsure if this behaviour is intentional anyway but my proposed documented solution is something I came across in the advanced pages router example, so I'm leaning towards interpereting this as intended behaviour.
Please let me know if there is a better place for this section (maybe a whole page under environments
dedicated to the pages router?), as I merely appended it to the file where it seemed to fit best.
I also did not come across any style guide for documentation in your repository, so I apologise in advance if anything I wrote is not up to standard. I'm more than happy to receive feedback and iterate on it :)