import { useUser, fetcher } from '../lib/hooks' import useSWR from 'swr' function UserList() { const { data: { users } = {} } = useSWR('/api/users', fetcher) return ( <>

All users

{!!users?.length && ( )} ) } export default function HomePage() { const [user] = useUser() return ( <>

Passport.js +{' '} next-connect{' '} Example

Steps to test the example:

Sign up

  1. Click Sign up and enter a username and password.
  2. You will be logged in and redirected home.
  3. Click Logout. You will be redirected home.
  4. Try sign up again with the same username, you will see an error.

Sign in

  1. Click Login and login again using the same credential.
  2. You will see an error if you use incorrect credential.
  3. Otherwise, you will be authenticated and redirected home.

Edit profile

  1. Click Profile
  2. Enter a new name and click Update profile.
  3. Notice how the name in Your profile has changed.
  4. Click Delete profile
  5. The user is removed and is no longer shown in All users section in Home
{user && ( <>

Currently logged in as:

{JSON.stringify(user, null, 2)}
)} ) }