Installation
Get started with Declarative Auth Forms in your Next.js project in just a few minutes.
1Prerequisites
Before you begin, make sure you have the following installed:
- Node.js 18.17 or later
- A Next.js 15 project with App Router
- shadcn/ui components set up in your project
2Install Dependencies
Install the required packages:
npm install declarative-auth-forms react-hook-form zod3Set Up Better Auth
If you haven't already, install and configure Better Auth:
npm install better-authCreate a lib/auth.ts file with your Better Auth configuration:
import { betterAuth } from "better-auth"
export const auth = betterAuth({
database: {
// Your database configuration
},
emailAndPassword: {
enabled: true,
},
})4Add shadcn/ui Components
Make sure you have the required shadcn/ui components:
npx shadcn@latest add button input label card form✓Quick Start
Create your first declarative auth form:
import { AuthForm } from "declarative-auth-forms"
const loginSchema = {
type: "login",
title: "Welcome back",
fields: [
{
name: "email",
type: "email",
label: "Email",
required: true
},
{
name: "password",
type: "password",
label: "Password",
required: true
}
],
submit: "Sign In"
}
export default function LoginPage() {
return <AuthForm schema={loginSchema} />
}You're all set!
You now have a fully functional authentication form. Check out the Schema Format documentation to learn about all available field types and validation options.