2.4.6 • Published 12 days ago

@hanzo/auth v2.4.6

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
12 days ago

Hanzo Auth

Initialization

Follow these steps to initialize authentication with Hanzo Auth for your project:

  1. Install package with pnpm i @hanzo/auth

  2. Create custom Header component that includes an AuthWidget from @hanzo/auth. See example in luxdefi/sites repo

  3. Edit root layout component

// ... other imports

import { AuthServiceProvider } from '@hanzo/auth/service'
import { getUserServerSide } from '@hanzo/auth/server'
import type { AuthServiceConf } from '@hanzo/auth/types'

// custom header with AuthWidget
import Header from '@/components/header'

// ...other code

const RootLayout: React.FC<PropsWithChildren> = async ({
  children
}) =>  {
  const currentUser = await getUserServerSide()

  return (
    <AuthServiceProvider user={currentUser} conf={{} as AuthServiceConf}>
      <RootLayoutCommon siteDef={siteDef} header={false} >
        <Header siteDef={siteDef}/>
        {children}
      </RootLayoutCommon>
    </AuthServiceProvider>
  )
}
export default RootLayout
  1. Create /api/auth/login route.
import { NextRequest } from 'next/server'

import { handleLoginApiRequest } from '@hanzo/auth/server'

export async function POST(request: NextRequest) {
  return handleLoginApiRequest(request)
}
  1. Create /api/auth/logout route.
import { handleLogoutApiRequest } from '@hanzo/auth/server'

export async function GET() {
  return handleLogoutApiRequest()
}
  1. Create /login route that uses LoginComponent from @hanzo/auth. See example in luxdefi/sites repo
2.4.5

12 days ago

2.4.6

12 days ago

2.4.1

14 days ago

2.4.0

14 days ago

2.4.3

14 days ago

2.4.2

14 days ago

2.4.4

14 days ago

2.3.6

16 days ago

2.3.5

20 days ago

2.3.4

29 days ago

2.3.3

1 month ago

2.3.2

1 month ago

2.3.1

1 month ago

2.3.0

1 month ago

2.2.1

1 month ago

2.2.0

1 month ago

2.1.0

1 month ago

2.0.4

2 months ago

2.0.3

2 months ago

2.0.2

2 months ago

2.0.1

2 months ago

1.2.0

2 months ago

1.1.1

2 months ago

1.1.0

2 months ago

1.1.9

2 months ago

1.1.8

2 months ago

1.1.7

2 months ago

1.1.6

2 months ago

1.1.5

2 months ago

1.1.4

2 months ago

1.1.3

2 months ago

1.1.2

2 months ago

1.1.10

2 months ago

2.0.0

2 months ago

1.0.14

2 months ago

1.0.13

2 months ago

1.0.12

2 months ago

1.0.9

2 months ago

1.0.8

2 months ago

1.0.11

2 months ago

1.0.10

2 months ago

0.1.10

2 months ago

0.1.11

2 months ago

0.1.12

2 months ago

0.1.13

2 months ago

0.1.9

2 months ago

0.1.8

2 months ago

0.1.7

2 months ago

0.1.6

2 months ago

0.1.5

2 months ago

0.1.4

2 months ago

0.1.3

2 months ago

0.1.2

2 months ago

0.1.1

2 months ago

0.1.0

2 months ago