docs: move client to authClient

This commit is contained in:
Bereket Engida
2024-10-13 21:40:51 +03:00
parent a29d4021cd
commit e5cfa6748c
2 changed files with 23 additions and 25 deletions
@@ -42,15 +42,13 @@ To signup a user, you can use the `signUp.email` function provided by the client
- `dontRememberMe`: If true, the user will be signed out when the browser session is closed. (optional)
```ts title="client.ts"
const signup = async () => {
const data = await client.signUp.email({
email: "test@example.com",
password: "password1234",
name: "test",
image: "https://example.com/image.png",
callbackURL: "/"
})
}
const { data, error } = await authClient.signUp.email({
email: "test@example.com",
password: "password1234",
name: "test",
image: "https://example.com/image.png",
callbackURL: "/"
})
```
### Signin
@@ -63,17 +61,19 @@ To signin a user, you can use the `signIn.email` function provided by the client
- `dontRememberMe`: If true, the user will be signed out when the browser is closed. (optional)
```ts title="client.ts"
import { createAuthClient } from "better-auth/client"
const client = createAuthClient()
const signin = async () => {
const data = await client.signIn.email({
const { data, error } = await authClient.signIn.email({
email: "test@example.com",
password: "password1234",
callbackURL: "/"
})
}
})
```
### Signout
To signout a user, you can use the `signOut` function provided by the client.
```ts title="client.ts"
await client.signOut()
```
### Email Verification
@@ -130,12 +130,10 @@ It takes an object with the following properties:
- `redirectTo`: The URL to redirect to after the user clicks on the link in the email. If the token is valid, the user will be redirected to this URL with the token in the query string. If the token is invalid, the user will be redirected to this URL with an error message in the query string `?error=invalid_token`.
```ts title="client.ts"
const forgetPassword = async () => {
const data = await client.forgetPassword({
email: "test@example.com",
redirectTo: "/reset-password"
})
}
const { data, error } = await client.forgetPassword({
email: "test@example.com",
redirectTo: "/reset-password"
})
```
When user click on the link in the email he will be redirected to the reset password page. You can add the reset password page to your app. Then you can use `resetPassword` function to reset the password. It takes an object with the following properties:
@@ -143,7 +141,7 @@ When user click on the link in the email he will be redirected to the reset pass
- `newPassword`: The new password of the user.
```ts title="client.ts"
const data = await client.resetPassword({
const { data, error } = await client.resetPassword({
newPassword: "password1234",
})
```
+1 -1
View File
@@ -7,4 +7,4 @@ This page contains information about security features of Better Auth.
## Reporting Vulnerabilities
If you have found a security vulnerability in Better Auth, please report it to us at [security@better-auth.com](mailto:security@betterstack.com). All reports will be promptly addressed, and you'll be credited accordingly.
If you have found a security vulnerability in Better Auth, please report it to us at [security@better-auth.com](mailto:security@betterstack.com). All reports will be promptly addressed, and you'll be credited accordingly.