Opionated minimal implementation of shared auth between multiple packages. Read more in article – Authentication in monorepo(NextJs, Astro) with Lucia and MongoDB
mysite.com
– landing page built with Astro Publicly available Provides login/signup page Redirects authenticated users toapp.mysite.com
app.mysite.com
– web application built with NextJs (app Router) Available only for authenticated users Provides sign-out feature Redirects unauthenticated users tomysite.com
- Astro
- NextJs (app router)
- Lucia-auth
- Mongoose
- TurboRepo
- npm
- dotenv
flowchart TB
auth-utils & web -->
db-utils
web & landing --->
auth-utils
db-utils
- provide simple db methods to work with MongoDb.CreateUser
,GetUser
. These methods are used byauth-utils
.auth-utils
- provide methods to create users and user sessions. Used byweb
andlanding
web
- web application, accessible only for authenticated users. Provides log-out functionlanding
- public landing page. Provides logout and login form. Inaccessible for authenticated users