Multiple apps sharing the same database using Better Auth
im using nextjs in a monorepo like this
apps:
example.com (account portal like billing etc)
product.example.com (spereate nextjs app)
what i do in nextauth is just share the same db and create new sessions for each user, is this do able in better auth
reason for this if you are wondering is because each product is very complex not always realted with each other, so would be lots to have on one app
question: is it possible to make it auto log in accross all subdomains if not them having to login again is fine for my use case just wondering and how would the config work just each nextjs app baseurl be set to that subdomain
4 Replies
@Ping @bekacru
You can use cross subdomain cookies which allows you to share the same cookie bwetween sub domains. Check the cookies section in the docs
once i set that, i can just change the baseURL for it and it will work?
fine
@Ping
?
sorry, not sure what you mean here. but it should work if you provide domain for cross subdomain cookies and if you enable it on prod