chore: docs optimizations

This commit is contained in:
KinfeMichael Tariku
2025-04-30 16:17:41 +03:00
committed by GitHub
parent bf83774db3
commit 5eafd4bd27
15 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -114,7 +114,7 @@ If the user clicks the provided verification URL, their email is automatically v
For manual verification, you can send the user a custom link with the `token` and call the `verifyEmail` function.
```ts
authClient.verifyEmail({
await authClient.verifyEmail({
query: {
token: "" // Pass the token here
}
+2 -2
View File
@@ -161,7 +161,7 @@ To handle rate limit errors on the client side, you can manage them either globa
```ts title="auth-client.ts"
import { createAuthClient } from "better-auth/client";
export const authClient = createAuthClient({
export const authClient = createAuthClient({
fetchOptions: {
onError: async (context) => {
const { response } = context;
@@ -178,7 +178,7 @@ export const authClient = createAuthClient({
**Per Request Handling**
```ts title="auth-client.ts"
import { client } from "./client";
import { authClient } from "./auth-client";
await authClient.signIn.email({
fetchOptions: {
@@ -187,7 +187,7 @@ const session = await authClient.getSession({ query: {
or on the server
```ts title="server.ts"
auth.api.getSession({
await auth.api.getSession({
query: {
disableCookieCache: true,
},
@@ -232,7 +232,7 @@ const authClient = createAuthClient({
plugins: [customSessionClient<typeof auth>()],
});
const { data } = await authClient.useSession();
const { data } = authClient.useSession();
const { data: sessionData } = await authClient.getSession();
// data.roles
// data.user.newField
+1 -1
View File
@@ -67,7 +67,7 @@ This plugin offers two main methods to do a second factor verification:
import { createAuthClient } from "better-auth/client"
import { twoFactorClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [
twoFactorClient()
]
+1 -1
View File
@@ -55,7 +55,7 @@ The Anonymous plugin allows users to have an authenticated experience without re
import { createAuthClient } from "better-auth/client"
import { anonymousClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [
anonymousClient()
]
+2 -2
View File
@@ -24,7 +24,7 @@ The API Key plugin allows you to create and manage API keys for your application
import { betterAuth } from "better-auth"
import { apiKey } from "better-auth/plugins"
const auth = betterAuth({
export const auth = betterAuth({
plugins: [ // [!code highlight]
apiKey() // [!code highlight]
] // [!code highlight]
@@ -57,7 +57,7 @@ The API Key plugin allows you to create and manage API keys for your application
import { createAuthClient } from "better-auth/client"
import { apiKeyClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [ // [!code highlight]
apiKeyClient() // [!code highlight]
] // [!code highlight]
+1 -1
View File
@@ -47,7 +47,7 @@ The **Captcha Plugin** integrates bot protection into your Better Auth system by
"x-captcha-response": turnstileToken, // [!code highlight]
"x-captcha-user-remote-ip": userIp, // optional: forwards the user's IP address to the captcha service // [!code highlight]
}, // [!code highlight]
},
}, // [!code highlight]
});
```
+1 -1
View File
@@ -37,7 +37,7 @@ The Email OTP plugin allows user to sign in, verify their email, or reset their
import { createAuthClient } from "better-auth/client"
import { emailOTPClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [
emailOTPClient()
]
+1 -1
View File
@@ -46,7 +46,7 @@ The Generic OAuth plugin provides a flexible way to integrate authentication wit
import { createAuthClient } from "better-auth/client"
import { genericOAuthClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [
genericOAuthClient()
]
+1 -1
View File
@@ -37,7 +37,7 @@ Magic link or email link is a way to authenticate users without a password. When
```ts title="auth-client.ts"
import { createAuthClient } from "better-auth/client";
import { magicLinkClient } from "better-auth/client/plugins";
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [
magicLinkClient()
]
+1 -1
View File
@@ -30,7 +30,7 @@ export const auth = betterAuth({
import { createAuthClient } from "better-auth/client"
import { multiSessionClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [
multiSessionClient()
]
+8 -8
View File
@@ -14,12 +14,12 @@ Add the One Tap plugin to your auth configuration:
```ts title="auth.ts"
import { betterAuth } from "better-auth";
import { oneTap } from "better-auth/plugins";
import { oneTap } from "better-auth/plugins"; // [!code highlight]
export const auth = betterAuth({
plugins: [
oneTap(), // Add the One Tap server plugin
]
plugins: [ // [!code highlight]
oneTap(), // Add the One Tap server plugin // [!code highlight]
] // [!code highlight]
});
```
@@ -32,7 +32,7 @@ Add the client plugin and specify where the user should be redirected after sign
import { createAuthClient } from "better-auth/client";
import { oneTapClient } from "better-auth/client/plugins";
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [
oneTapClient({
clientId: "YOUR_CLIENT_ID",
@@ -70,7 +70,7 @@ By default, after a successful login the plugin will hard redirect the user to `
Pass fetchOptions with an onSuccess callback to handle the login response without a page reload:
```ts
authClient.oneTap({
await authClient.oneTap({
fetchOptions: {
onSuccess: () => {
// For example, use a router to navigate without a full reload:
@@ -85,7 +85,7 @@ authClient.oneTap({
To perform a hard redirect to a different page after login, use the callbackURL option:
```ts
authClient.oneTap({
await authClient.oneTap({
callbackURL: "/dashboard"
});
```
@@ -97,7 +97,7 @@ If the user dismisses or skips the prompt, the plugin will retry showing the One
If the maximum number of attempts is reached without a successful sign-in, you can use the onPromptNotification callback to be notified—allowing you to render an alternative UI (e.g., a traditional Google Sign-In button) so users can restart the process manually:
```ts
authClient.oneTap({
await authClient.oneTap({
onPromptNotification: (notification) => {
console.warn("Prompt was dismissed or skipped. Consider displaying an alternative sign-in option.", notification);
// Render your alternative UI here
+1 -1
View File
@@ -49,7 +49,7 @@ export const auth = betterAuth({
import { createAuthClient } from "better-auth/client"
import { organizationClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [ // [!code highlight]
organizationClient() // [!code highlight]
] // [!code highlight]
+1 -1
View File
@@ -76,7 +76,7 @@ The passkey plugin implementation is powered by [SimpleWebAuthn](https://simplew
import { createAuthClient } from "better-auth/client"
import { passkeyClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [ // [!code highlight]
passkeyClient() // [!code highlight]
] // [!code highlight]
+2 -2
View File
@@ -15,7 +15,7 @@ The username plugin wraps the email and password authenticator and adds username
import { betterAuth } from "better-auth"
import { username } from "better-auth/plugins"
const auth = betterAuth({
export const auth = betterAuth({
plugins: [ // [!code highlight]
username() // [!code highlight]
] // [!code highlight]
@@ -48,7 +48,7 @@ The username plugin wraps the email and password authenticator and adds username
import { createAuthClient } from "better-auth/client"
import { usernameClient } from "better-auth/client/plugins"
const authClient = createAuthClient({
export const authClient = createAuthClient({
plugins: [ // [!code highlight]
usernameClient() // [!code highlight]
] // [!code highlight]