Get Started
Set up authentication with Notion UI and Better Auth.
This example connects Notion UI to Better Auth. See Notion Auth for full example.
Basic Usage
Setup Auth instance with BETTER-AUTH
Follow the tutorial on BETTER-AUTH to set up your auth instance.
Install Auth UI from Notion UI
pnpm add @notion-kit/auth-uiAdd an AuthProvider at the root of your application
// app/layout.tsx
import { AuthProvider } from "@notion-kit/auth-ui";
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<AuthProvider
/**
* The base URL of the server.
* You can use `https://notion-authn.vercel.app` for testing.
*/
authURL={...}
>
<main>{children}</main>
</AuthProvider>
);
}Now, let's add a LoginForm to your root page
// app/page.tsx
import { LoginForm } from "@notion-kit/auth-ui";
export default function Page() {
return (
<div className="flex h-screen w-screen flex-col items-center justify-center gap-10 bg-main">
<h1 className="text-lg font-bold text-primary">Login Page</h1>
<LoginForm
mode="sign_in"
callbackURL="/protected"
className="w-80"
/>
</div>
);
}