mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 04:19:32 +00:00
40 lines
1.3 KiB
Plaintext
40 lines
1.3 KiB
Plaintext
---
|
|
title: Next js example
|
|
description: Better Auth next js example
|
|
---
|
|
|
|
This is an example of how to use Better Auth with Next.
|
|
|
|
**Implements the following features:**
|
|
Email & Password . Social Sign-in . Passkeys . Email Verification . Password Reset . Two Factor Authentication . Profile Update . Session Management . Organizaition, Members and Roles
|
|
|
|
See [Demo](https://demo.better-auth.com)
|
|
|
|
<ForkButton url="better-auth/better-auth/tree/main/examples/nextjs-example" />
|
|
|
|
<iframe src="https://stackblitz.com/github/better-auth/better-auth/tree/main/demo/nextjs?codemirror=1&fontsize=14&hidenavigation=1&runonclick=1&hidedevtools=1"
|
|
style={{
|
|
width: "100%",
|
|
height: "500px",
|
|
border: 0,
|
|
borderRadius: "4px",
|
|
overflow: "hidden"
|
|
}}
|
|
title="Better Auth Next Js Example"
|
|
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
|
|
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
>
|
|
</iframe>
|
|
|
|
|
|
## How to run
|
|
|
|
1. Clone the code sandbox (or the repo) and open it in your code editor
|
|
2. Move .env.example to .env and provide necessary variables
|
|
3. Run the following commands
|
|
```bash
|
|
pnpm install
|
|
pnpm dev
|
|
```
|
|
4. Open the browser and navigate to `http://localhost:3000`
|