supastarter for Next.jsAPI
Use locale in API endpoints
Learn how to use the users locale in your supastarter API endpoints.
Sometimes you need to use the users locale in your API endpoints. For example, you might want to fetch data from a database that is localized or if you want to send an email in the users locale.
To make the users locale available in your endpoint handler, you can use the localeMiddleware
.
This middleware will either provide the locale from the locale cookie of the user or the default locale of the application.