@authaz/next
v1.0.10
Published
NextJS authaz SDK
Downloads
1,072
Readme
@authaz/next
Next.js SDK for Authaz authentication.
Installation
npm install @authaz/next @authaz/sdk
# or
pnpm add @authaz/next @authaz/sdk
# or
yarn add @authaz/next @authaz/sdkUsage
API Routes Setup
// app/api/auth/[...authaz]/route.ts
import { createAuthazHandler } from '@authaz/next';
export const { GET, POST } = createAuthazHandler({
clientId: process.env.AUTHAZ_CLIENT_ID!,
clientSecret: process.env.AUTHAZ_CLIENT_SECRET!,
});Middleware
// middleware.ts
import { withAuthaz } from '@authaz/next';
export default withAuthaz();
export const config = {
matcher: ['/dashboard/:path*', '/api/:path*'],
};Server Components
import { getSession } from '@authaz/next';
async function Page() {
const session = await getSession();
if (!session) {
return <div>Not authenticated</div>;
}
return <div>Hello, {session.user?.name}</div>;
}Documentation
For full documentation, visit https://authaz.io/docs
License
MIT
