{"_id":"@daveyplate/better-auth-triplit","_rev":"7-c53302b59ea5d9158f38b5a0020e4883","name":"@daveyplate/better-auth-triplit","dist-tags":{"latest":"0.2.2"},"versions":{"0.1.0":{"name":"@daveyplate/better-auth-triplit","version":"0.1.0","keywords":["typescript","better-auth","triplit","auth","authentication"],"author":{"name":"daveycodez"},"license":"MIT","_id":"@daveyplate/better-auth-triplit@0.1.0","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/better-auth-triplit","dist":{"shasum":"7a5c3073c33ceb0ac03171fd1c4c041b5cc44af8","tarball":"https://registry.npmjs.org/@daveyplate/better-auth-triplit/-/better-auth-triplit-0.1.0.tgz","fileCount":11,"integrity":"sha512-9ih5XaHoRtLFpNw4zUheULeX8nFTsNDUG9Keg9GAmmDtUh17oVyjZqrST9gEIEGo/A1LztlYZNFJUjQ+p83jaQ==","signatures":[{"sig":"MEUCIHp/uR/v7A0cChx3cKGuphbtIRfVWlb6MdTxZ0TXzDDdAiEAmMgALfM7nCDD64WrPubZMN6Y+nAQe0jFcldrQYZieTw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":41564},"types":"dist/index","module":"dist/index","exports":"./dist/index.js","gitHead":"d9c9dc3f2b35949c3c10a926d00675145c0e81c6","scripts":{"dev":"tsc-watch --onSuccess 'biome check --fix'","build":"tsup --clean --dts","prepublishOnly":"rm -rf dist && tsup --clean --dts"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"10.9.2","description":"Better Auth adapter for Triplit","directories":{},"_nodeVersion":"22.15.0","dependencies":{"jose":"^6.0.10"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1","devDependencies":{"tsx":"^4.19.3","tsup":"^8.4.0","react":"^19.1.0","turbo":"^2.5.0","react-dom":"^19.1.0","tsc-watch":"^6.2.1","typescript":"^5.8.3","@types/node":"^22.14.1","@types/react":"^19.1.2","@types/react-dom":"^19.1.2","esbuild-plugin-preserve-directives":"^0.0.11"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0","better-auth":">=1.0.0","@triplit/client":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/better-auth-triplit_0.1.0_1746428550523_0.11872265523309222","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@daveyplate/better-auth-triplit","version":"0.1.1","keywords":["typescript","better-auth","triplit","auth","authentication"],"author":{"name":"daveycodez"},"license":"MIT","_id":"@daveyplate/better-auth-triplit@0.1.1","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/better-auth-triplit","dist":{"shasum":"ea89162e520d478d1a28400fe1b5880890958b5c","tarball":"https://registry.npmjs.org/@daveyplate/better-auth-triplit/-/better-auth-triplit-0.1.1.tgz","fileCount":11,"integrity":"sha512-tM0eilN2lV3Srxp59IIK25iknnMNCCKx3yQpBE1KtGd9nu1d34mtVJWwrfN6zYGNXnmSeWB1LdiYmrHHD8GOFw==","signatures":[{"sig":"MEUCIQDf/Y5CC/YHxiy4gvkbXFSL/Gfh9IsnVCIGqyAnU/hLQwIgOBN0kuz6wuNpBu5zxVoGGNcV80QgZ+ouNJh49n7YR28=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43127},"types":"dist/index","module":"dist/index","exports":"./dist/index.js","gitHead":"a66e980edcb7b15bb62717de43df3e6bba2f3e8d","scripts":{"dev":"tsc-watch --onSuccess 'biome check --fix'","build":"tsup --clean --dts","prepublishOnly":"rm -rf dist && tsup --clean --dts"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"10.9.2","description":"Better Auth adapter for Triplit","directories":{},"_nodeVersion":"22.15.0","dependencies":{"jose":"^6.0.10"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1","devDependencies":{"tsx":"^4.19.3","tsup":"^8.4.0","react":"^19.1.0","turbo":"^2.5.0","react-dom":"^19.1.0","tsc-watch":"^6.2.1","typescript":"^5.8.3","@types/node":"^22.14.1","@types/react":"^19.1.2","@types/react-dom":"^19.1.2","esbuild-plugin-preserve-directives":"^0.0.11"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0","better-auth":">=1.0.0","@triplit/client":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/better-auth-triplit_0.1.1_1746754059949_0.6836320610603825","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@daveyplate/better-auth-triplit","version":"0.1.2","keywords":["typescript","better-auth","triplit","auth","authentication"],"author":{"name":"daveycodez"},"license":"MIT","_id":"@daveyplate/better-auth-triplit@0.1.2","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/better-auth-triplit","dist":{"shasum":"cecf3c895e59cb08a3c5e748937d5eb8e961a72b","tarball":"https://registry.npmjs.org/@daveyplate/better-auth-triplit/-/better-auth-triplit-0.1.2.tgz","fileCount":11,"integrity":"sha512-COqUs/OS5IueCAEqmcEk9nCIKd6ia81loJenVCapMykrLKM6Nv4v2Wip+Ud+HWwGY7uw5R7/o44scrX84E78bA==","signatures":[{"sig":"MEQCIH/foD92IgcHqwk3XF5stXUh1HbapW1xKGRQoKIulYtiAiAQCbLqhajNTeWb2E9t3/eboZd0GO/lBadpJKYO17K+fQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43779},"types":"dist/index","module":"dist/index","exports":"./dist/index.js","gitHead":"63502c020feae4e8ea0b91e5007d75c1d6e9c75a","scripts":{"dev":"tsc-watch --onSuccess 'biome check --fix'","build":"tsup --clean --dts","prepublishOnly":"rm -rf dist && tsup --clean --dts"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"11.0.0","description":"Better Auth adapter for Triplit","directories":{},"_nodeVersion":"22.11.0","dependencies":{"jose":"^6.0.10"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1","devDependencies":{"tsx":"^4.19.3","tsup":"^8.4.0","react":"^19.1.0","turbo":"^2.5.0","react-dom":"^19.1.0","tsc-watch":"^6.2.1","typescript":"^5.8.3","@types/node":"^22.14.1","@types/react":"^19.1.2","@types/react-dom":"^19.1.2","esbuild-plugin-preserve-directives":"^0.0.11"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0","better-auth":">=1.0.0","@triplit/client":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/better-auth-triplit_0.1.2_1747470117824_0.6605593128026657","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@daveyplate/better-auth-triplit","version":"0.2.0","keywords":["typescript","better-auth","triplit","auth","authentication"],"author":{"name":"daveycodez"},"license":"MIT","_id":"@daveyplate/better-auth-triplit@0.2.0","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/better-auth-triplit","dist":{"shasum":"abdfffbc720017c01654f8cdbfc32a84852f9ef1","tarball":"https://registry.npmjs.org/@daveyplate/better-auth-triplit/-/better-auth-triplit-0.2.0.tgz","fileCount":13,"integrity":"sha512-UqNw+aQIzQm2bTqiByH5H29cBMYrity4QGoegpyApxdrFutaQy3jgDIOKgeG72AXZjcc3e0mOBURQKXzzbaEWQ==","signatures":[{"sig":"MEUCIQCVjIP0X/zGG5a4P/a+f2Xl47QAg2feLZuOI2YCzqsDeQIgP8Rmfzhv5zlNvIfaOTOWFLFm3eWkyEo671ovMHPDzwo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":53546},"types":"dist/index","module":"dist/index","exports":"./dist/index.js","gitHead":"1ee57967509bf785d3c0218ee3848a70509ecb33","scripts":{"dev":"tsc-watch --onSuccess 'biome check --fix'","build":"tsup --clean --dts","prepublishOnly":"rm -rf dist && tsup --clean --dts"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"11.0.0","description":"Better Auth adapter for Triplit","directories":{},"_nodeVersion":"22.11.0","dependencies":{"jose":"^6.0.11"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1","devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","react":"^19.1.0","turbo":"^2.5.4","react-dom":"^19.1.0","tsc-watch":"^7.1.1","typescript":"^5.8.3","@types/node":"^24.0.13","@types/react":"^19.1.8","@biomejs/biome":"2.1.1","@types/react-dom":"^19.1.6","esbuild-plugin-preserve-directives":"^0.0.11"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0","better-auth":">=1.0.0","@triplit/react":">=1.0.46","@triplit/client":">=1.0.46"},"_npmOperationalInternal":{"tmp":"tmp/better-auth-triplit_0.2.0_1752398225130_0.5550027807682887","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@daveyplate/better-auth-triplit","version":"0.2.1","keywords":["typescript","better-auth","triplit","auth","authentication"],"author":{"name":"daveycodez"},"license":"MIT","_id":"@daveyplate/better-auth-triplit@0.2.1","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/better-auth-triplit","dist":{"shasum":"3b72b9a70df6be4b7673f3978a1b281deb508c57","tarball":"https://registry.npmjs.org/@daveyplate/better-auth-triplit/-/better-auth-triplit-0.2.1.tgz","fileCount":13,"integrity":"sha512-fe4C2Ay2ukehhxCSIxgo/6vBLai6ivnov8P5ibXzkO107RgzSgivkE4KJaNJ1NMvRam68Ve1GIJPXRg1gza3Ag==","signatures":[{"sig":"MEUCIQCUwPKK9vaxght+wY0NFCY0wWgcppJE5o84OzrnI5q1/gIgXElLHZdtJS3LaF7950fBetp1BSWR++pEHmDbwNzwL44=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52921},"types":"dist/index","module":"dist/index","exports":"./dist/index.js","gitHead":"26cc559b139b0e477319b91b5e8910a352fd3629","scripts":{"dev":"tsc-watch --onSuccess 'biome check --fix'","build":"tsup --clean --dts","prepublishOnly":"rm -rf dist && tsup --clean --dts"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"10.9.2","description":"Better Auth adapter for Triplit","directories":{},"_nodeVersion":"22.15.0","dependencies":{"jose":"^6.0.11"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1","devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","react":"^19.1.0","turbo":"^2.5.4","react-dom":"^19.1.0","tsc-watch":"^7.1.1","typescript":"^5.8.3","@types/node":"^24.0.13","@types/react":"^19.1.8","@biomejs/biome":"2.1.1","@types/react-dom":"^19.1.6","esbuild-plugin-preserve-directives":"^0.0.11"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0","better-auth":">=1.0.0","@triplit/react":">=1.0.46","@triplit/client":">=1.0.46"},"_npmOperationalInternal":{"tmp":"tmp/better-auth-triplit_0.2.1_1752447499355_0.9426941739195804","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@daveyplate/better-auth-triplit","version":"0.2.2","keywords":["typescript","better-auth","triplit","auth","authentication"],"author":{"name":"daveycodez"},"license":"MIT","_id":"@daveyplate/better-auth-triplit@0.2.2","maintainers":[{"name":"leakeddave","email":"leakeddave@me.com"}],"homepage":"https://github.com/daveyplate/better-auth-triplit","dist":{"shasum":"04658ad8dc5cd7f4333835c6de9365f74dbc1529","tarball":"https://registry.npmjs.org/@daveyplate/better-auth-triplit/-/better-auth-triplit-0.2.2.tgz","fileCount":13,"integrity":"sha512-dnsQ2d9Ues8nEpobIAf322FFHyaT3QQOD3qxVo0+wWXNCFRWEbIwMOCtIwEIn4dgtJQcMktU2XCwvi2/pQ9ruw==","signatures":[{"sig":"MEUCIGvjMnkQJYRkPSxU2EnrFLGo0WJtS0RMvUbdAdp4aMn5AiEAkEWi7VdMn3RFICIC5nV4WWHG88R7eK122cd5rLe51mI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":59341},"types":"dist/index","module":"dist/index","exports":"./dist/index.js","gitHead":"d580844b4a69b96f033aab8688ce62c20321b038","scripts":{"dev":"tsc-watch --onSuccess 'biome check --fix'","build":"tsup --clean --dts","prepublishOnly":"rm -rf dist && tsup --clean --dts"},"_npmUser":{"name":"leakeddave","email":"leakeddave@me.com"},"_npmVersion":"11.0.0","description":"Better Auth adapter for Triplit","directories":{},"_nodeVersion":"22.11.0","dependencies":{"jose":"^6.0.11"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.8.1","devDependencies":{"tsx":"^4.20.3","tsup":"^8.5.0","react":"^19.1.0","turbo":"^2.5.4","react-dom":"^19.1.0","tsc-watch":"^7.1.1","typescript":"^5.8.3","@types/node":"^24.0.13","@types/react":"^19.1.8","@biomejs/biome":"2.1.1","@types/react-dom":"^19.1.6","esbuild-plugin-preserve-directives":"^0.0.11"},"peerDependencies":{"react":">=18.0.0","react-dom":">=18.0.0","better-auth":">=1.0.0","@triplit/react":">=1.0.46","@triplit/client":">=1.0.46"},"_npmOperationalInternal":{"tmp":"tmp/better-auth-triplit_0.2.2_1753174226203_0.27100494434693756","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-05-05T07:02:30.437Z","modified":"2025-11-21T03:13:00.408Z","0.1.0":"2025-05-05T07:02:30.698Z","0.1.1":"2025-05-09T01:27:40.128Z","0.1.2":"2025-05-17T08:21:58.023Z","0.2.0":"2025-07-13T09:17:05.340Z","0.2.1":"2025-07-13T22:58:19.528Z","0.2.2":"2025-07-22T08:50:26.364Z"},"author":{"name":"daveycodez"},"license":"MIT","homepage":"https://github.com/daveyplate/better-auth-triplit","keywords":["typescript","better-auth","triplit","auth","authentication"],"description":"Better Auth adapter for Triplit","maintainers":[{"email":"leakeddave@me.com","name":"leakeddave"},{"email":"daveycodez@gmail.com","name":"daveycodez"}],"readme":"# Better Auth Triplit Adapter\n\nThis package provides an adapter for [Better Auth](https://better-auth.com/) to use [Triplit](https://triplit.dev/) as a database backend.\n\n## Installation\n\n```bash\n# Using npm\nnpm install @daveyplate/better-auth-triplit\n\n# Using yarn\nyarn add @daveyplate/better-auth-triplit\n\n# Using pnpm\npnpm add @daveyplate/better-auth-triplit\n```\n\n## Auth Schema\n\n### auth-schema.ts\n```typescript\nimport { Schema as S } from \"@triplit/client\"\n\nexport const authSchema = S.Collections({\n    users: {\n        schema: S.Schema({\n            id: S.Id(),\n            name: S.String(),\n            email: S.String(),\n            emailVerified: S.Boolean({ default: false }),\n            image: S.Optional(S.String()),\n            createdAt: S.Date({ default: S.Default.now() }),\n            updatedAt: S.Date({ default: S.Default.now() })\n        }),\n        relationships: {\n            sessions: S.RelationMany(\"sessions\", {\n                where: [[\"userId\", \"=\", \"$id\"]]\n            }),\n            accounts: S.RelationMany(\"accounts\", {\n                where: [[\"userId\", \"=\", \"$id\"]]\n            })\n        },\n        permissions: {\n            authenticated: {\n                read: {\n                    filter: [[\"id\", \"=\", \"$token.sub\"]]\n                }\n            }\n        }\n    },\n    sessions: {\n        schema: S.Schema({\n            id: S.Id(),\n            userId: S.String(),\n            token: S.String(),\n            expiresAt: S.Date(),\n            ipAddress: S.Optional(S.String()),\n            userAgent: S.Optional(S.String()),\n            createdAt: S.Date({ default: S.Default.now() }),\n            updatedAt: S.Date({ default: S.Default.now() })\n        }),\n        relationships: {\n            user: S.RelationById(\"users\", \"$userId\")\n        },\n        permissions: {\n            authenticated: {\n                read: {\n                    filter: [[\"userId\", \"=\", \"$token.sub\"]]\n                }\n            }\n        }\n    },\n    accounts: {\n        schema: S.Schema({\n            id: S.Id(),\n            userId: S.String(),\n            accountId: S.String(),\n            providerId: S.String(),\n            accessToken: S.Optional(S.String()),\n            refreshToken: S.Optional(S.String()),\n            accessTokenExpiresAt: S.Optional(S.Date()),\n            refreshTokenExpiresAt: S.Optional(S.Date()),\n            scope: S.Optional(S.String()),\n            idToken: S.Optional(S.String()),\n            password: S.Optional(S.String()),\n            createdAt: S.Date({ default: S.Default.now() }),\n            updatedAt: S.Date({ default: S.Default.now() })\n        }),\n        relationships: {\n            user: S.RelationById(\"users\", \"$userId\")\n        },\n        permissions: {\n            authenticated: {\n                read: {\n                    filter: [[\"userId\", \"=\", \"$token.sub\"]]\n                }\n            }\n        }\n    },\n    verifications: {\n        schema: S.Schema({\n            id: S.Id(),\n            identifier: S.String(),\n            value: S.String(),\n            expiresAt: S.Date(),\n            createdAt: S.Date({ default: S.Default.now() }),\n            updatedAt: S.Date({ default: S.Default.now() })\n        }),\n        permissions: {}\n    }\n})\n```\n\n## Usage\n\n```typescript\nimport { betterAuth } from \"better-auth\";\nimport { HttpClient } from \"@triplit/client\"\nimport { schema } from \"./schema\"\n\nexport const httpClient = new HttpClient({\n    schema,\n    serverUrl: process.env.NEXT_PUBLIC_TRIPLIT_DB_URL,\n    token: process.env.TRIPLIT_SERVICE_TOKEN\n})\n\n// Create a Better Auth instance with Triplit adapter\nconst auth = betterAuth({\n  database: triplitAdapter({\n    httpClient,\n    debugLogs: false, // Optional: enable for debugging\n    usePlural: true,  // Optional: set to false if your schema uses singular names\n  }),\n  // Other Better Auth options\n});\n\n// Now you can use Better Auth as usual\n// auth.signIn(...), auth.signUp(...), etc.\n```\n\n## Configuration Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `httpClient` | `HTTPClient` | required | The Triplit HTTPClient instance with service token |\n| `debugLogs` | `boolean` | `false` | Enable detailed logging for debugging |\n| `usePlural` | `boolean` | `true` | Whether table names in the schema are plural |\n| `secretKey` | `string` | `process.env.BETTER_AUTH_SECRET` | Secret key for signing the JWT |\n\n## JWT\n\nThe JWT is now accessible via useSession. It can be found on data.session.token. Here is an example React hook on how to synchronize your Better Auth state with Triplit. I'll likely make an easy to use hook for this in the future. We default to using your BETTER_AUTH_SECRET from process.env.BETTER_AUTH_SECRET for signing JWT's. You must also configure this on your Triplit server.\n\n```ts\nimport { authClient } from \"@/lib/auth-client\"\nimport { triplit } from \"@/triplit/client\"\nimport { useEffect } from \"react\"\nimport { toast } from \"sonner\"\nimport { useSession } from \"./auth-hooks\"\n\nexport function useTriplitAuth() {\n    const { data: sessionData, isPending, refetch: refetchSession } = useSession()\n\n    useEffect(() => {\n        if (isPending) return\n\n        const startSession = async () => {\n            try {\n                await triplit.startSession(\n                    sessionData?.session.token || process.env.NEXT_PUBLIC_TRIPLIT_ANON_TOKEN!\n                )\n            } catch (error) {\n                console.error(error)\n                toast.error((error as Error).message)\n\n                if (sessionData) {\n                    authClient.signOut().then(() => {\n                        refetchSession()\n                    })\n                }\n            }\n        }\n\n        startSession()\n    }, [isPending, sessionData, refetchSession])\n}\n```\n\n## License\n\nMIT","readmeFilename":"README.md"}