A Better Auth plugin for Attio that provides bidirectional sync between your application and Attio, enabling user management, organization sync, and session tracking directly from Attio
- Sync users, workspaces and arbitrary database objects between your Better Auth app and Attio in both directions
- Create users, ban/unban them, and send password reset emails directly from Attio
- View active sessions with device and browser information and revoke them remotely
- Manage organization members and handle invitations across both systems
- Impersonate users for support and debugging purposes
npm install better-auth-attio-plugin
# or
pnpm add better-auth-attio-plugin
# or
bun add better-auth-attio-pluginVisit the Attio Connection Generator to create your connection secret:
- Enter your application's live URL (e.g.,
https://your-app.com) - Enter the path to your Better Auth endpoints (default:
/api/auth) - Generate the connection secret
- Copy the generated base64-encoded connection string
Add the Attio plugin to your Better Auth configuration:
import { betterAuth } from "better-auth";
import { attio } from "better-auth-attio-plugin";
export const auth = betterAuth({
// ... your other config
plugins: [
attio({
secret: process.env.ATTIO_SECRET, // Shared secret for authentication from step 1
waitUntil: ctx.waitUntil, // Defer sync until after response is sent, for edge environments like Cloudflare Workers
passwordResetRedirectTo: "/reset-password", // Optional: URL where users reset their password (defaults to "/reset-password")
}),
// You'll also want the admin, and organization plugins for full functionality
admin(),
organization(),
],
});In Attio:
- Navigate to Settings > Apps
- Install the Better Auth integration
- Paste the connection string from step 1
- The app will automatically set up the required objects and attributes
By default, the plugin syncs users and organizations with predefined field mappings. You can customize this behavior with adapters.
Adapters control how data is transformed between Better Auth and Attio. Use them to:
- Add custom fields to the sync
- Change field mappings
- Sync custom database models to any Attio object
import { userAdapter } from "better-auth-attio-plugin/adapters";
attio({
secret: process.env.ATTIO_SECRET,
adapters: [
{
...userAdapter,
// Add custom fields to Attio
attioSchema: {
...userAdapter.attioSchema,
subscription_tier: {
type: "text",
title: "Subscription Tier",
},
},
// Map data when syncing to Attio
toAttio: async (event, values, ctx) => {
const base = await userAdapter.toAttio(event, values, ctx);
return {
...base,
subscription_tier: values.metadata?.tier || "free",
};
},
},
],
})Note
You can create adapters for any Better Auth model to sync with any Attio object, not just users and organizations.
Note
This app is provided free of charge & published under the permissive MIT License. If you use it for your company, please consider to sponsor me on GitHub to support further development and continued maintenance of the Better Auth Attio App.
MIT License Copyright © 2025 Tobias Möritz