mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-10 04:19:32 +00:00
docs: add dub plugin docs
This commit is contained in:
@@ -519,7 +519,6 @@ export const contents: Content[] = [
|
||||
{
|
||||
title: "Kick",
|
||||
href: "/docs/authentication/kick",
|
||||
isNew: true,
|
||||
icon: () => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -554,7 +553,6 @@ export const contents: Content[] = [
|
||||
{
|
||||
title: "Tiktok",
|
||||
href: "/docs/authentication/tiktok",
|
||||
isNew: true,
|
||||
icon: () => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -720,7 +718,6 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
|
||||
},
|
||||
{
|
||||
title: "VK",
|
||||
isNew: true,
|
||||
href: "/docs/authentication/vk",
|
||||
icon: () => (
|
||||
<svg
|
||||
@@ -1271,7 +1268,6 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
|
||||
{
|
||||
title: "API Key",
|
||||
href: "/docs/plugins/api-key",
|
||||
isNew: true,
|
||||
icon: () => <KeyRound className="size-4" />,
|
||||
},
|
||||
{
|
||||
@@ -1477,7 +1473,6 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
|
||||
{
|
||||
title: "Polar",
|
||||
href: "/docs/plugins/polar",
|
||||
isNew: true,
|
||||
icon: () => (
|
||||
<svg
|
||||
width="1.2em"
|
||||
@@ -1513,7 +1508,6 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
|
||||
{
|
||||
title: "Stripe",
|
||||
href: "/docs/plugins/stripe",
|
||||
isNew: true,
|
||||
icon: () => (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@@ -1532,6 +1526,27 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Dub",
|
||||
href: "/docs/plugins/dub",
|
||||
isNew: true,
|
||||
icon: () => (
|
||||
<svg
|
||||
width="1.2em"
|
||||
height="1.2em"
|
||||
viewBox="0 0 65 64"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
clip-rule="evenodd"
|
||||
d="M32.5 64C50.1731 64 64.5 49.6731 64.5 32C64.5 20.1555 58.0648 9.81393 48.5 4.28099V31.9999V47.9998H40.5V45.8594C38.1466 47.2207 35.4143 47.9999 32.5 47.9999C23.6634 47.9999 16.5 40.8364 16.5 31.9999C16.5 23.1633 23.6634 15.9999 32.5 15.9999C35.4143 15.9999 38.1466 16.779 40.5 18.1404V1.00812C37.943 0.350018 35.2624 0 32.5 0C14.8269 0 0.500038 14.3269 0.500038 32C0.500038 49.6731 14.8269 64 32.5 64Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
</svg>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Community Plugins",
|
||||
href: "/docs/plugins/community-plugins",
|
||||
|
||||
146
docs/content/docs/plugins/dub.mdx
Normal file
146
docs/content/docs/plugins/dub.mdx
Normal file
@@ -0,0 +1,146 @@
|
||||
---
|
||||
title: Dub
|
||||
description: Better Auth Plugin for Lead Tracking using Dub links and OAuth Linking
|
||||
---
|
||||
|
||||
[Dub](https://dub.co/) is an open source modern link management platform for entrepreneurs, creators, and growth teams.
|
||||
|
||||
This plugins allows you to track leads when a user signs up using a Dub link. It also adds OAuth linking support to allow you to build integrations extending Dub's linking management infrastructure.
|
||||
|
||||
## Installation
|
||||
|
||||
<Steps>
|
||||
<Step>
|
||||
### Install the plugin
|
||||
First, install the plugin:
|
||||
|
||||
```package-install
|
||||
@dub/better-auth
|
||||
```
|
||||
</Step>
|
||||
<Step>
|
||||
### Install the Dub SDK
|
||||
|
||||
Next, install the Dub SDK on your server:
|
||||
|
||||
```package-install
|
||||
dub
|
||||
```
|
||||
</Step>
|
||||
<Step>
|
||||
### Configure the plugin
|
||||
|
||||
Add the plugin to your auth config:
|
||||
|
||||
```ts title="auth.ts"
|
||||
import { betterAuth } from "better-auth"
|
||||
import { dubAnalytics } from "@dub/better-auth"
|
||||
import { dub } from "dub"
|
||||
|
||||
export const auth = betterAuth({
|
||||
plugins: [
|
||||
dubAnalytics({
|
||||
dubClient: new Dub()
|
||||
})
|
||||
]
|
||||
})
|
||||
```
|
||||
</Step>
|
||||
|
||||
</Steps>
|
||||
|
||||
## Usage
|
||||
|
||||
### Lead Tracking
|
||||
|
||||
By default, the plugin will track sign up events as leads. You can disable this by setting `disableLeadTracking` to `true`.
|
||||
|
||||
```ts
|
||||
import { dubAnalytics } from "@dub/better-auth";
|
||||
import { betterAuth } from "better-auth";
|
||||
import { Dub } from "dub";
|
||||
|
||||
const dub = new Dub();
|
||||
|
||||
const betterAuth = betterAuth({
|
||||
plugins: [
|
||||
dubAnalytics({
|
||||
dubClient: dub,
|
||||
disableLeadTracking: true, // Disable lead tracking
|
||||
}),
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### OAuth Linking
|
||||
|
||||
The plugin supports OAuth for account linking.
|
||||
|
||||
First, you need to setup OAuth app in Dub. Dub supports OAuth 2.0 authentication, which is recommended if you build integrations extending Dub’s functionality [Learn more about OAuth](https://dub.co/docs/integrations/quickstart#integrating-via-oauth-2-0-recommended).
|
||||
|
||||
Once you get the client ID and client secret, you can configure the plugin.
|
||||
|
||||
```ts
|
||||
dubAnalytics({
|
||||
dubClient: dub,
|
||||
oauth: {
|
||||
clientId: "your-client-id",
|
||||
clientSecret: "your-client-secret",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
And in the client, you need to use the `dubAnalyticsClient` plugin.
|
||||
|
||||
```ts
|
||||
import { createAuthClient } from "better-auth/client";
|
||||
import { dubAnalyticsClient } from "@dub/better-auth/client";
|
||||
|
||||
const authClient = createAuthClient({
|
||||
plugins: [dubAnalyticsClient()],
|
||||
});
|
||||
```
|
||||
|
||||
To link account with Dub, you need to use the `dub.link`.
|
||||
|
||||
```ts
|
||||
const response = await authClient.dub.link({
|
||||
callbackURL: "/dashboard", // URL to redirect to after linking
|
||||
});
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
You can pass the following options to the plugin:
|
||||
|
||||
### `dubClient`
|
||||
|
||||
The Dub client instance.
|
||||
|
||||
### `disableLeadTracking`
|
||||
|
||||
Disable lead tracking for sign up events.
|
||||
|
||||
### `leadEventName`
|
||||
|
||||
Event name for sign up leads.
|
||||
|
||||
### `customLeadTrack`
|
||||
|
||||
Custom lead track function.
|
||||
|
||||
### `oauth`
|
||||
|
||||
Dub OAuth configuration.
|
||||
|
||||
### `oauth.clientId`
|
||||
|
||||
Client ID for Dub OAuth.
|
||||
|
||||
### `oauth.clientSecret`
|
||||
|
||||
Client secret for Dub OAuth.
|
||||
|
||||
### `oauth.pkce`
|
||||
|
||||
Enable PKCE for Dub OAuth.
|
||||
@@ -6,7 +6,9 @@ description: Better Auth Plugin for Payment and Checkouts using Polar
|
||||
[Polar](https://polar.sh) is a developer first payment infrastructure. Out of the box it provides a lot of developer first integrations for payments, checkouts and more. This plugin helps you integrate Polar with Better Auth to make your auth + payments flow seamless.
|
||||
|
||||
<Callout>
|
||||
This plugin is maintained by Polar team. For bugs, issues or feature requests, please visit the [Polar GitHub repo](https://github.com/polarsource/polar-adapters).
|
||||
This plugin is maintained by Polar team. For bugs, issues or feature requests,
|
||||
please visit the [Polar GitHub
|
||||
repo](https://github.com/polarsource/polar-adapters).
|
||||
</Callout>
|
||||
|
||||
## Installation
|
||||
@@ -75,11 +77,12 @@ This plugin is maintained by Polar team. For bugs, issues or feature requests, p
|
||||
});
|
||||
```
|
||||
</Step>
|
||||
|
||||
</Steps>
|
||||
|
||||
<Callout>
|
||||
There is no client configuration required. You don't need to pass any configuration options to the `createAuthClient` function.
|
||||
There is no client configuration required. You don't need to pass any
|
||||
configuration options to the `createAuthClient` function.
|
||||
</Callout>
|
||||
|
||||
|
||||
For configuration options and more information, check out [Polar's Better Auth docs](https://docs.polar.sh/integrate/sdk/adapters/better-auth#configuration-options).
|
||||
|
||||
Reference in New Issue
Block a user