How theadroitdev/next-js-auth works
Project type and purpose
• This is a full-stack Next.js (React) application, bootstrapped with create-next-app.
• It combines server-side rendering (SSR), client-side React pages, and serverless API routes under the same codebase.
• The primary features revolve around user authentication and profiles: signup, login, logout, “me” lookup, and profile viewing.
File structure
Top level:
• next.config.mjs, tsconfig.json, tailwind.config.ts, package.json ⟶ project configuration
• src/app ⟶ the Next.js “app” directory:
– page.tsx, layout.tsx, globals.css ⟶ global layout, styles, root page
– subfolders login, signup, profile/[id] ⟶ React page components for each route
– api/users/*/route.ts ⟶ four serverless API endpoints: signup, login, logout, me
• src/dbconfig/dbConfig.ts ⟶ database connection setup
• src/models/userModel.js ⟶ user schema/model (likely MongoDB/Mongoose or similar)
• src/helpers/getDataFromTokens.ts ⟶ JWT/token utility
• src/middleware.ts ⟶ global request middleware (e.g. auth guard)
README for additional insights
• Confirms it’s Next.js with built-in routing, SSR, and optimization (fonts, CSS, tailwind).
Final advice
• Be exhaustive: include every folder of consequence (app router, api, models, helpers).
• Detail the data flows for signup and login: form → API → DB → token → cookie → middleware → protected page.
• SSR flow: request to Next.js server → layout.tsx → page.tsx → possible fetch calls to API → HTML + JS delivered.