How to persist next-intl locale during social-provider sign-up?
I can’t figure out how to reliably save the user’s locale during social-provider sign-up (Google, GitHub, etc.).
My app uses next-intl, so the locale is always a path param (/en/…, /cs/…).
With email+password I simply send locale in the body, but OAuth redirects lose this value.
Current attempt
Client (Next.js 15 + better-auth 1.3.2):
Server after hook:
What I’m missing
-How should I forward the locale so the callback handler can read it?
-Which exact path (/callback/:provider?) and which field (query.state, query.locale, body?) should I check?
-Is there a built-in way to pass arbitrary data (like locale) through the OAuth flow, or must I use cookies / custom state?
Happy to refactor the code—just need the canonical pattern.
Thanks!
My app uses next-intl, so the locale is always a path param (/en/…, /cs/…).
With email+password I simply send locale in the body, but OAuth redirects lose this value.
Current attempt
Client (Next.js 15 + better-auth 1.3.2):
Server after hook:
What I’m missing
-How should I forward the locale so the callback handler can read it?
-Which exact path (/callback/:provider?) and which field (query.state, query.locale, body?) should I check?
-Is there a built-in way to pass arbitrary data (like locale) through the OAuth flow, or must I use cookies / custom state?
Happy to refactor the code—just need the canonical pattern.
Thanks!
