Skip to content

Commit f7218aa

Browse files
committed
fix: update naming to better-auth DC-6120
1 parent 7f01e6d commit f7218aa

File tree

4 files changed

+52
-52
lines changed

4 files changed

+52
-52
lines changed

content/800-guides/230-betterauth-nextjs.mdx

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
title: 'How to use Prisma ORM with Better-Auth and Next.js'
3-
metaTitle: 'How to use Prisma ORM and Prisma Postgres with Better-Auth and Next.js'
4-
description: 'Learn how to use Prisma ORM in a Next.js app with Better-Auth'
5-
sidebar_label: 'Better-Auth (with Next.js)'
2+
title: 'How to use Prisma ORM with Better Auth and Next.js'
3+
metaTitle: 'How to use Prisma ORM and Prisma Postgres with Better Auth and Next.js'
4+
description: 'Learn how to use Prisma ORM in a Next.js app with Better Auth'
5+
sidebar_label: 'Better Auth (with Next.js)'
66
image: '/img/guides/prisma-betterauth-nextjs-cover.png'
77
completion_time: '25 min'
88
community_section: true
99
---
1010

1111
## Introduction
1212

13-
[Better-Auth](https://better-auth.com/) is a modern, open-source authentication solution for web applications. It's built with TypeScript and provides a simple and extensible auth experience with support for multiple database adapters, including Prisma.
13+
[Better Auth](https://better-auth.com/) is a modern, open-source authentication solution for web applications. It's built with TypeScript and provides a simple and extensible auth experience with support for multiple database adapters, including Prisma.
1414

15-
In this guide, you'll wire Better-Auth into a brand-new [Next.js](https://nextjs.org/) app and persist users in a [Prisma Postgres](https://prisma.io/postgres) database. You can find a complete example of this guide on [GitHub](https://github.com/prisma/prisma-examples/tree/latest/orm/betterauth-nextjs).
15+
In this guide, you'll wire Better Auth into a brand-new [Next.js](https://nextjs.org/) app and persist users in a [Prisma Postgres](https://prisma.io/postgres) database. You can find a complete example of this guide on [GitHub](https://github.com/prisma/prisma-examples/tree/latest/orm/betterauth-nextjs).
1616

1717
## Prerequisites
1818

@@ -78,7 +78,7 @@ Once installed, initialize Prisma in your project:
7878
npx prisma init --db --output ../src/generated/prisma
7979
```
8080
:::info
81-
You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better-Auth Project"
81+
You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Project"
8282
:::
8383

8484
This will create:
@@ -149,19 +149,19 @@ We recommend using a connection pooler (like [Prisma Accelerate](https://www.pri
149149
If you choose not to use one, **avoid** instantiating `PrismaClient` globally in long-lived environments. Instead, create and dispose of the client per request to prevent exhausting your database connections.
150150
:::
151151

152-
## 3. Set up Better-Auth
152+
## 3. Set up Better Auth
153153

154-
Now it's time to integrate Better-Auth for authentication.
154+
Now it's time to integrate Better Auth for authentication.
155155

156-
### 3.1. Install and configure Better-Auth
156+
### 3.1. Install and configure Better Auth
157157

158-
First, install the Better-Auth core package:
158+
First, install the Better Auth core package:
159159

160160
```terminal
161161
npm install better-auth
162162
```
163163

164-
Next, generate a secure secret that Better-Auth will use to sign authentication tokens. This ensures your tokens cannot be messed with.
164+
Next, generate a secure secret that Better Auth will use to sign authentication tokens. This ensures your tokens cannot be messed with.
165165

166166
```terminal
167167
npx @better-auth/cli@latest secret
@@ -170,7 +170,7 @@ npx @better-auth/cli@latest secret
170170
Copy the generated secret and add it, along with your application's URL, to your `.env` file:
171171

172172
```dotenv file=.env showLineNumbers
173-
# Better-Auth
173+
# Better Auth
174174
//add-start
175175
BETTER_AUTH_SECRET=your-generated-secret
176176
BETTER_AUTH_URL=http://localhost:3000
@@ -180,13 +180,13 @@ BETTER_AUTH_URL=http://localhost:3000
180180
DATABASE_URL="your-database-url"
181181
```
182182

183-
Now, create a configuration file for Better-Auth. In the `src/lib` directory, create an `auth.ts` file:
183+
Now, create a configuration file for Better Auth. In the `src/lib` directory, create an `auth.ts` file:
184184

185185
```terminal
186186
touch src/lib/auth.ts
187187
```
188188

189-
In this file, you'll configure Better-Auth to use the Prisma adapter, which allows it to persist user and session data in your database. You will also enable email and password authentication.
189+
In this file, you'll configure Better Auth to use the Prisma adapter, which allows it to persist user and session data in your database. You will also enable email and password authentication.
190190

191191
```ts file=src/lib/auth.ts
192192
import { betterAuth } from 'better-auth'
@@ -200,7 +200,7 @@ export const auth = betterAuth({
200200
})
201201
```
202202

203-
Better-Auth also supports other sign-in methods like social logins (Google, GitHub, etc.), which you can explore in their [documentation](https://www.better-auth.com/docs/authentication/email-password).
203+
Better Auth also supports other sign-in methods like social logins (Google, GitHub, etc.), which you can explore in their [documentation](https://www.better-auth.com/docs/authentication/email-password).
204204

205205
```ts file=src/lib/auth.ts
206206
import { betterAuth } from 'better-auth'
@@ -240,9 +240,9 @@ export const auth = betterAuth({
240240
```
241241
:::
242242

243-
### 3.2. Add Better-Auth models to your schema
243+
### 3.2. Add Better Auth models to your schema
244244

245-
Better-Auth provides a CLI command to automatically add the necessary authentication models (`User`, `Session`, `Account`, and `Verification`) to your `schema.prisma` file.
245+
Better Auth provides a CLI command to automatically add the necessary authentication models (`User`, `Session`, `Account`, and `Verification`) to your `schema.prisma` file.
246246

247247
Run the following command:
248248

@@ -329,7 +329,7 @@ npx prisma migrate dev --name add-auth-models
329329

330330
## 4. Set up the API routes
331331

332-
Better-Auth needs an API endpoint to handle authentication requests like sign-in, sign-up, and sign-out. You'll create a catch-all API route in Next.js to handle all requests sent to `/api/auth/[...all]`.
332+
Better Auth needs an API endpoint to handle authentication requests like sign-in, sign-up, and sign-out. You'll create a catch-all API route in Next.js to handle all requests sent to `/api/auth/[...all]`.
333333

334334
In the `src/app/api` directory, create an `auth/[...all]` folder structure and a `route.ts` file inside it:
335335

@@ -338,7 +338,7 @@ mkdir -p "src/app/api/auth/[...all]"
338338
touch "src/app/api/auth/[...all]/route.ts"
339339
```
340340

341-
Add the following code to the newly created `route.ts` file. This code uses a helper from Better-Auth to create Next.js-compatible `GET` and `POST` request handlers.
341+
Add the following code to the newly created `route.ts` file. This code uses a helper from Better Auth to create Next.js-compatible `GET` and `POST` request handlers.
342342

343343
```ts
344344
import { auth } from "@/lib/auth";
@@ -414,7 +414,7 @@ export default function SignUpPage() {
414414
}
415415
```
416416

417-
Now, import the `signUp` function from your Better-Auth client and add the `handleSubmit` function. This function is triggered on form submission and calls the `signUp.email` method provided by Better-Auth, passing the user's name, email, and password.
417+
Now, import the `signUp` function from your Better Auth client and add the `handleSubmit` function. This function is triggered on form submission and calls the `signUp.email` method provided by Better Auth, passing the user's name, email, and password.
418418

419419
```tsx file=src/app/sign-up/page.tsx
420420
"use client";
@@ -615,7 +615,7 @@ export default function SignInPage() {
615615
}
616616
```
617617

618-
Add the `handleSubmit` function, this time importing and using the `signIn.email` method from Better-Auth.
618+
Add the `handleSubmit` function, this time importing and using the `signIn.email` method from Better Auth.
619619

620620
```tsx file=src/app/sign-in/page.tsx
621621
"use client";
@@ -782,7 +782,7 @@ export default function DashboardPage() {
782782
}
783783
```
784784

785-
Import the `useSession` hook from your Better-Auth client. This hook is the key to managing authentication state on the client side. It provides the session data and a pending status.
785+
Import the `useSession` hook from your Better Auth client. This hook is the key to managing authentication state on the client side. It provides the session data and a pending status.
786786

787787
```tsx file=src/app/dashboard/page.tsx
788788
"use client";
@@ -971,7 +971,7 @@ npx prisma studio
971971

972972
:::success
973973

974-
Congratulations! You now have a fully functional authentication system built with Better-Auth, Prisma, and Next.js.
974+
Congratulations! You now have a fully functional authentication system built with Better Auth, Prisma, and Next.js.
975975

976976
:::
977977

@@ -985,6 +985,6 @@ Congratulations! You now have a fully functional authentication system built wit
985985

986986
## Further reading
987987

988-
- [Better-Auth documentation](https://www.better-auth.com/docs)
988+
- [Better Auth documentation](https://www.better-auth.com/docs)
989989
- [Prisma documentation](/orm/overview/introduction)
990990
- [Next.js App Router](https://nextjs.org/docs/app)

content/800-guides/380-vercel-app-deployment.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Experience the instant deployment flow with [our interactive demo](https://pris.
2323

2424
**Available examples:**
2525
- **Next.js + Prisma**: Basic full-stack application with database integration
26-
- **Next.js + Prisma + Better-Auth**: Complete application with authentication using [Better-Auth](https://www.better-auth.com/)
26+
- **Next.js + Prisma + Better Auth**: Complete application with authentication using [Better Auth](https://www.better-auth.com/)
2727

2828
**Demo features:**
2929

content/800-guides/400-betterauth-astro.mdx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
---
2-
title: 'How to use Prisma ORM with Better-Auth and Astro'
3-
metaTitle: 'How to use Prisma ORM and Prisma Postgres with Better-Auth and Astro'
4-
description: 'Learn how to use Prisma ORM in an Astro app with Better-Auth'
5-
sidebar_label: 'Better-Auth (with Astro)'
2+
title: 'How to use Prisma ORM with Better Auth and Astro'
3+
metaTitle: 'How to use Prisma ORM and Prisma Postgres with Better Auth and Astro'
4+
description: 'Learn how to use Prisma ORM in an Astro app with Better Auth'
5+
sidebar_label: 'Better Auth (with Astro)'
66
image: '/img/guides/prisma-betterauth-astro-cover.png'
77
completion_time: '25 min'
88
community_section: true
99
---
1010

1111
## Introduction
1212

13-
[Better-Auth](https://better-auth.com/) is a modern, open-source authentication solution for web applications. It's built with TypeScript and provides a simple and extensible auth experience with support for multiple database adapters, including Prisma.
13+
[Better Auth](https://better-auth.com/) is a modern, open-source authentication solution for web applications. It's built with TypeScript and provides a simple and extensible auth experience with support for multiple database adapters, including Prisma.
1414

15-
In this guide, you'll wire Better-Auth into a brand-new [Astro](https://astro.build/) app and persist users in a [Prisma Postgres](https://prisma.io/postgres) database. You can find a complete example of this guide on [GitHub](https://github.com/prisma/prisma-examples/tree/latest/orm/betterauth-astro).
15+
In this guide, you'll wire Better Auth into a brand-new [Astro](https://astro.build/) app and persist users in a [Prisma Postgres](https://prisma.io/postgres) database. You can find a complete example of this guide on [GitHub](https://github.com/prisma/prisma-examples/tree/latest/orm/betterauth-astro).
1616

1717
## Prerequisites
1818

@@ -72,7 +72,7 @@ npx prisma init --db --output ../prisma/generated
7272
```
7373

7474
:::info
75-
You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better-Auth Astro Project"
75+
You'll need to answer a few questions while setting up your Prisma Postgres database. Select the region closest to your location and a memorable name for your database like "My Better Auth Astro Project"
7676
:::
7777

7878
This will create:
@@ -156,19 +156,19 @@ We recommend using a connection pooler (like [Prisma Accelerate](https://www.pri
156156
If you choose not to use one, **avoid** instantiating `PrismaClient` globally in long-lived environments. Instead, create and dispose of the client per request to prevent exhausting your database connections.
157157
:::
158158

159-
## 3. Set up Better-Auth
159+
## 3. Set up Better Auth
160160

161-
Now it's time to integrate Better-Auth for authentication.
161+
Now it's time to integrate Better Auth for authentication.
162162

163-
### 3.1. Install and configure Better-Auth
163+
### 3.1. Install and configure Better Auth
164164

165-
First, install the Better-Auth core package:
165+
First, install the Better Auth core package:
166166

167167
```terminal
168168
npm install better-auth
169169
```
170170

171-
Next, generate a secure secret that Better-Auth will use to sign authentication tokens. This ensures your tokens cannot be tampered with.
171+
Next, generate a secure secret that Better Auth will use to sign authentication tokens. This ensures your tokens cannot be tampered with.
172172

173173
```terminal
174174
npx @better-auth/cli@latest secret
@@ -177,7 +177,7 @@ npx @better-auth/cli@latest secret
177177
Copy the generated secret and add it, along with your application's URL, to your `.env` file:
178178

179179
```dotenv file=.env showLineNumbers
180-
# Better-Auth
180+
# Better Auth
181181
//add-start
182182
BETTER_AUTH_SECRET=your-generated-secret
183183
BETTER_AUTH_URL=http://localhost:4321
@@ -191,13 +191,13 @@ DATABASE_URL="your-database-url"
191191
Astro's default development server runs on port `4321`. If your application runs on a different port, update the `BETTER_AUTH_URL` accordingly.
192192
:::
193193

194-
Now, create a configuration file for Better-Auth. In the `src/lib` directory, create an `auth.ts` file:
194+
Now, create a configuration file for Better Auth. In the `src/lib` directory, create an `auth.ts` file:
195195

196196
```terminal
197197
touch src/lib/auth.ts
198198
```
199199

200-
In this file, you'll configure Better-Auth to use the Prisma adapter, which allows it to persist user and session data in your database. You will also enable email and password authentication.
200+
In this file, you'll configure Better Auth to use the Prisma adapter, which allows it to persist user and session data in your database. You will also enable email and password authentication.
201201

202202
```ts file=src/lib/auth.ts
203203
import { betterAuth } from "better-auth";
@@ -214,11 +214,11 @@ export const auth = betterAuth({
214214
});
215215
```
216216

217-
Better-Auth also supports other sign-in methods like social logins (Google, GitHub, etc.), which you can explore in their [documentation](https://www.better-auth.com/docs/authentication/email-password).
217+
Better Auth also supports other sign-in methods like social logins (Google, GitHub, etc.), which you can explore in their [documentation](https://www.better-auth.com/docs/authentication/email-password).
218218

219-
### 3.2. Add Better-Auth models to your schema
219+
### 3.2. Add Better Auth models to your schema
220220

221-
Better-Auth provides a CLI command to automatically add the necessary authentication models (`User`, `Session`, `Account`, and `Verification`) to your `schema.prisma` file.
221+
Better Auth provides a CLI command to automatically add the necessary authentication models (`User`, `Session`, `Account`, and `Verification`) to your `schema.prisma` file.
222222

223223
Run the following command:
224224

@@ -306,7 +306,7 @@ npx prisma migrate dev --name add-auth-models
306306

307307
## 4. Set up the API routes
308308

309-
Better-Auth needs an API endpoint to handle authentication requests like sign-in, sign-up, and sign-out. You'll create a catch-all API route in Astro to handle all requests sent to `/api/auth/[...all]`.
309+
Better Auth needs an API endpoint to handle authentication requests like sign-in, sign-up, and sign-out. You'll create a catch-all API route in Astro to handle all requests sent to `/api/auth/[...all]`.
310310

311311
In the `src/pages` directory, create an `api/auth` folder structure and a `[...all].ts` file inside it:
312312

@@ -315,7 +315,7 @@ mkdir -p src/pages/api/auth
315315
touch 'src/pages/api/auth/[...all].ts'
316316
```
317317

318-
Add the following code to the newly created `[...all].ts` file. This code uses the Better-Auth handler to process authentication requests.
318+
Add the following code to the newly created `[...all].ts` file. This code uses the Better Auth handler to process authentication requests.
319319

320320
```ts file=src/pages/api/auth/[...all].ts
321321
import { auth } from "../../../lib/auth";
@@ -472,7 +472,7 @@ export const prerender = false;
472472
</html>
473473
```
474474

475-
Now add a script to handle form submission. Import the `authClient` and add an event listener to the form that prevents the default submission behavior, extracts the form data, and calls the Better-Auth sign-up method.
475+
Now add a script to handle form submission. Import the `authClient` and add an event listener to the form that prevents the default submission behavior, extracts the form data, and calls the Better Auth sign-up method.
476476

477477
```html file=src/pages/sign-up/index.astro
478478
---
@@ -639,7 +639,7 @@ export const prerender = false;
639639
</html>
640640
```
641641
642-
Now add a script to handle form submission. Import the `authClient` and add an event listener that prevents default submission, extracts the form data, and calls the Better-Auth sign-in method.
642+
Now add a script to handle form submission. Import the `authClient` and add an event listener that prevents default submission, extracts the form data, and calls the Better Auth sign-in method.
643643
644644
```html file=src/pages/sign-in/index.astro
645645
---
@@ -864,11 +864,11 @@ export const prerender = false;
864864
<head>
865865
<meta charset="utf-8" />
866866
<meta name="viewport" content="width=device-width" />
867-
<title>Better-Auth + Astro + Prisma</title>
867+
<title>Better Auth + Astro + Prisma</title>
868868
</head>
869869
<body>
870870
<main>
871-
<h1>Better-Auth + Astro + Prisma</h1>
871+
<h1>Better Auth + Astro + Prisma</h1>
872872
{
873873
Astro.locals.user ? (
874874
<div>
@@ -911,7 +911,7 @@ npx prisma studio
911911
912912
:::success
913913
914-
Congratulations! You now have a fully functional authentication system built with Better-Auth, Prisma, and Astro.
914+
Congratulations! You now have a fully functional authentication system built with Better Auth, Prisma, and Astro.
915915
916916
:::
917917
@@ -925,6 +925,6 @@ Congratulations! You now have a fully functional authentication system built wit
925925
926926
## Further reading
927927
928-
- [Better-Auth documentation](https://www.better-auth.com/docs)
928+
- [Better Auth documentation](https://www.better-auth.com/docs)
929929
- [Prisma documentation](/orm/overview/introduction)
930930
- [Astro documentation](https://astro.build/docs)
223 KB
Loading

0 commit comments

Comments
 (0)