Skip to main content
Sync your Better Auth users to Sequenzy with a simple plugin. When users sign up, they’re automatically added as subscribers—enabling welcome emails, onboarding sequences, and more.

Installation

Install the official Sequenzy plugin for Better Auth:
npm install @sequenzy/better-auth
# or
bun add @sequenzy/better-auth
# or
pnpm add @sequenzy/better-auth

Quick Setup

1. Get Your API Key

  1. Go to Settings → API Keys in Sequenzy
  2. Click Create API Key
  3. Copy the key and add it to your environment variables:
SEQUENZY_API_KEY=sk_live_xxxxxxxxxxxxx

2. Add the Plugin

Add the Sequenzy plugin to your Better Auth configuration:
auth.ts
import { betterAuth } from "better-auth";
import { sequenzy } from "@sequenzy/better-auth";

export const auth = betterAuth({
  // ... your existing config
  plugins: [
    sequenzy({
      apiKey: process.env.SEQUENZY_API_KEY!,
    }),
  ],
});

3. Add Client Plugin (Optional)

For TypeScript type inference, add the client plugin:
auth-client.ts
import { createAuthClient } from "better-auth/client";
import { sequenzyClient } from "@sequenzy/better-auth/client";

export const authClient = createAuthClient({
  plugins: [sequenzyClient()],
});
That’s it! New users will now be automatically synced to Sequenzy.

Configuration Options

sequenzy({
  // Required: Your Sequenzy API key
  apiKey: process.env.SEQUENZY_API_KEY!,

  // Optional: Add subscribers to specific lists only
  // Default: Adds to all lists
  listIds: ["list_welcome", "list_newsletter"],

  // Optional: Tags to assign to new subscribers
  tags: ["signup", "better-auth"],

  // Optional: Enroll in automation sequences
  // Default: true
  enrollInSequences: true,

  // Optional: Extract custom attributes from the user
  getCustomAttributes: (user) => ({
    authProvider: "better-auth",
    signupDate: new Date().toISOString(),
  }),

  // Optional: Success callback
  onSubscriberCreated: ({ userId, email, subscriberId }) => {
    console.log(`Synced ${email} to Sequenzy`);
  },

  // Optional: Error callback
  onError: (error, user) => {
    console.error(`Failed to sync ${user.email}:`, error.message);
  },
});

What Gets Synced

When a user signs up through Better Auth, Sequenzy automatically:
  1. Creates a new subscriber with their email
  2. Syncs profile data (name parsed into first/last)
  3. Adds to specified lists (or all lists if not specified)
  4. Triggers any matching automations

Synced Attributes

AttributeSource
emailUser’s email address
firstNameFirst word of user’s name
lastNameRemaining words of user’s name
Custom attributesVia getCustomAttributes option

List Assignment

Add to All Lists (Default)

By default, new subscribers are added to all lists in your Sequenzy account:
sequenzy({
  apiKey: process.env.SEQUENZY_API_KEY!,
  // No listIds = all lists
});

Add to Specific Lists

To add subscribers to specific lists only:
sequenzy({
  apiKey: process.env.SEQUENZY_API_KEY!,
  listIds: ["list_abc123", "list_def456"],
});

Add to No Lists

To create subscribers without list assignment:
sequenzy({
  apiKey: process.env.SEQUENZY_API_KEY!,
  listIds: [], // Empty array = no lists
});

Supported Auth Methods

The plugin hooks into these Better Auth flows:
MethodEndpointSynced
Email/Password/sign-up/emailYes
Google OAuth/callback/googleYes
GitHub OAuth/callback/githubYes
Other OAuth/callback/*Yes
Both new registrations and new OAuth sign-ups are synced. Returning OAuth users (already have an account) are not re-synced.

Using with Automations

Welcome Sequence

Create an automation to welcome every new user:
  1. Go to AutomationsCreate New
  2. Set trigger to Contact Added
  3. Add your welcome email sequence
  4. Activate the automation
Every Better Auth signup will now receive your welcome sequence.

Personalization

Use synced attributes in your emails:
Hi {{firstName}},

Welcome! We're excited to have you on board.

Error Handling

The plugin is non-blocking by design. If Sequenzy is unavailable:
  • Authentication succeeds normally
  • User account is created
  • Error is logged (if onError is set)
sequenzy({
  apiKey: process.env.SEQUENZY_API_KEY!,
  onError: (error, user) => {
    // Log to your error tracking service
    Sentry.captureException(error, {
      extra: { userEmail: user.email },
    });
  },
});

Custom Attributes

Add any data you want to track:
sequenzy({
  apiKey: process.env.SEQUENZY_API_KEY!,
  getCustomAttributes: (user) => ({
    userId: user.id,
    hasAvatar: !!user.image,
    signupSource: "web",
    signupTimestamp: Date.now(),
  }),
});
These attributes are available in:
  • Subscriber profiles
  • Email personalization
  • Segment filters
  • Automation conditions

Tagging Signups

Tag new subscribers for organization or automation triggers:
sequenzy({
  apiKey: process.env.SEQUENZY_API_KEY!,
  tags: ["signup", "better-auth", "web-app"],
});
You can then:
  • Filter subscribers by tag
  • Trigger automations on tag assignment
  • Create segments based on tags

FAQ

No, only new sign-ups after adding the plugin are synced. Existing users need to be imported separately via the API or CSV upload.
The plugin uses Sequenzy’s upsert API—existing subscribers get their attributes merged, not duplicated.
Yes, set enrollInSequences: false to create subscribers without triggering automations.
No. The plugin runs asynchronously after authentication succeeds. Auth flow is never delayed or blocked.
Authentication succeeds normally. The sync failure is logged via onError if provided.
Yes, the Better Auth integration is included at no extra cost.

Source Code

The plugin is open source:

GitHub Repository

View source, report issues, or contribute