← Back to Library|PromptsAdd Authentication to Your App

Add Authentication to Your App

Set up user authentication with sign-up, sign-in, session management, and protected routes in one structured prompt.

10-15 min|Intermediate
BuildDeep WorkDeveloper
Prompt Template
Look at my project and add authentication. Check my package.json and existing code to determine my framework, then recommend the best auth approach for my stack.

Set up the full auth flow:
1. Sign up with email/password and at least one OAuth provider (Google or GitHub)
2. Sign in with the same methods
3. Session management using secure, HttpOnly cookies
4. Protected routes for any pages that need auth (check my route structure)
5. A way to access the current user in both server and client components
6. Redirect unauthenticated users away from protected routes
7. Sign out that clears the session

Do NOT implement password reset or email verification in this pass. Do NOT store passwords in plaintext. Do NOT put auth tokens in localStorage."

**Output format:** Auth provider setup + sign-in/up component + route protection logic.

Listing every auth flow (sign up, sign in, sign out, protection, redirects) prevents the AI from building half the system and leaving you to figure out the rest.

Early in your project, after initial scaffolding. Auth touches many files, so it's easier to add before you have dozens of pages.

Add Authentication to Your App | Library | Modern Vibe Coding