mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-25 00:22:43 -05:00
docs: use type-only import for BetterAuthClientPlugin (#7565)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
@@ -461,7 +461,7 @@ const myPlugin = () => {
|
||||
If your endpoints need to be called from the client, you'll also need to create a client plugin. Better Auth clients can infer the endpoints from the server plugins. You can also add additional client-side logic.
|
||||
|
||||
```ts title="client-plugin.ts"
|
||||
import type { BetterAuthClientPlugin } from "better-auth";
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
|
||||
export const myPluginClient = () => {
|
||||
return {
|
||||
|
||||
@@ -164,7 +164,7 @@ First, let’s create our `client.ts` file first:
|
||||
</Files>
|
||||
Then, add the following code:
|
||||
```ts title="client.ts"
|
||||
import { BetterAuthClientPlugin } from "better-auth";
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
import type { birthdayPlugin } from "./index"; // make sure to import the server plugin as a type // [!code highlight]
|
||||
|
||||
type BirthdayPlugin = typeof birthdayPlugin;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { BetterAuthClientPlugin } from "better-auth";
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
import type { scim } from "./index";
|
||||
|
||||
export const scimClient = () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { BetterAuthClientPlugin } from "better-auth";
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
import type { SSOPlugin } from "./index";
|
||||
|
||||
interface SSOClientOptions {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { BetterAuthClientPlugin } from "better-auth";
|
||||
import type { BetterAuthClientPlugin } from "better-auth/client";
|
||||
import type { stripe } from "./index";
|
||||
|
||||
export const stripeClient = <
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import type { BetterAuthOptions } from "@better-auth/core";
|
||||
import type { Auth, InferUser } from "better-auth";
|
||||
import type { AuthClient } from "better-auth/client";
|
||||
import { expectTypeOf, test } from "vitest";
|
||||
|
||||
test("expect imports", async () => {
|
||||
expectTypeOf<AuthClient<{}>>().not.toBeUndefined();
|
||||
});
|
||||
|
||||
test("infer user type correctly", async () => {
|
||||
const config = {
|
||||
user: {
|
||||
|
||||
Reference in New Issue
Block a user