Commit ca71a4f
feat(auth-next-client,auth-next-server): add default auth with auto-detection
Implement default authentication for auth-next-client/server packages
to provide zero-config setup for developers.
auth-next-server changes:
- Add createDefaultAuthConfig() function with optional configuration
- Auto-detect clientId based on environment (sandbox vs production)
- Auto-derive redirectUri from window.location.origin + '/callback'
- Export default client IDs and constants for consumer use
- Uses public Immutable client IDs for development convenience
auth-next-client changes:
- Update useLogin hook to accept optional config (all fields)
- Update useLogout hook to accept optional config
- Add helper functions to create complete configs with defaults
- Auto-detect clientId, redirectUri, popupRedirectUri, logoutRedirectUri
- Export default constants for direct consumer use
This enables minimal setup:
// Server (lib/auth.ts)
export const { handlers, auth } = NextAuth(createDefaultAuthConfig());
// Client
const { loginWithPopup } = useLogin();
await loginWithPopup(); // No config needed!
const { logout } = useLogout();
await logout(); // No config needed!
Consumers can still override any field as needed for production use.
Related to wallet package default auth implementation (PR #2768).
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent ec905d5 commit ca71a4f
6 files changed
Lines changed: 363 additions & 31 deletions
File tree
- packages
- auth-next-client/src
- auth-next-server/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
0 commit comments