Relative Content

Tag Archive for typescriptnext.js

Type-safe routes with [locale] pathname segment

What’s the best approach to typing app routes for an i18n app? Previously I just read the request headers (cookies and accept-language) to get the locale, and the experiemental typedRoutes feature worked perfectly. I was recently convinced to move the locale into the pathname. I can still write paths without including the locale segment. The middleware then redirects to the correct path by doing the same lookup as before. However it would save a round-trip and a little compute to just include the current locale in the path to begin with. I’m using i18next if that matters.

Where or how do i store JWT access token in a next.js app router app?

I’ve got a backend that uses a JWT auth, when i log in, it sends me access token in the body of the response and refresh token in http-only cookies. I get the part with the refresh-token, it’s attached on every request, fine, but what about access token. What’s the most convinient way to store it?