Usage on the Server
In general you can use messages and the languageTag()
function on the server without issues.
There are a few things to be aware of:
- Messages are just functions. Make sure they are called somewhere that's evaluated for every request.
Using the Language in Server Actions
Use the initializeLanguage
function at the top of your server-action file to make sure the language is available.
Chaining Middleware
Paraglide-Next comes with middleware. Often you will want to chain that middleware with your own.
Just call Paraglide-Next's middleware inside your own middleware function. Pass it the request and use the returned response.
Using the language in Middleware
In some cases you may need to access the language of a request inside the middleware itself. For this the middleware
function provides a detectLanguage
function.