This document provides instructions for setting up Kinde authentication in your Next.js application.
Update the .env.local file with your actual Kinde credentials:
# Kinde Configuration
KINDE_CLIENT_ID=your_actual_kinde_client_id
KINDE_CLIENT_SECRET=your_actual_kinde_client_secret
KINDE_ISSUER_URL=https://your_subdomain.kinde.com
KINDE_SITE_URL=http://localhost:3000
KINDE_POST_LOGOUT_REDIRECT_URL=http://localhost:3000
KINDE_POST_LOGIN_REDIRECT_URL=http://localhost:3000/files
http://localhost:3000/api/auth/kinde_callbackhttp://localhost:3000http://localhost:3000The application now includes:
/api/auth/login/api/auth/register/api/auth/logout/api/auth/callbackYou can use the authentication components in your pages:
import { LoginButton, LogoutButton, RegisterButton } from "@/app/components/authButtons";
// In your component
<LoginButton />
<LogoutButton />
<RegisterButton />
To access user information in client components:
import { useKindeBrowserClient } from "@kinde-oss/kinde-auth-nextjs";
const { user, isLoading } = useKindeBrowserClient();
For server-side components and API routes:
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
const { getUser, isAuthenticated } = getKindeServerSession();
npm run devhttp://localhost:3000/files