{"_id":"better-auth-instantdb","_rev":"6-7f06335a863ee5d26d88aacf49f47d44","name":"better-auth-instantdb","dist-tags":{"latest":"1.3.4"},"versions":{"1.3.0":{"name":"better-auth-instantdb","version":"1.3.0","keywords":["typescript","instantdb","better","better-auth","auth","authentication","adapter"],"author":{"name":"daveycodez"},"license":"MIT","_id":"better-auth-instantdb@1.3.0","maintainers":[{"name":"daveycodez","email":"daveycodez@gmail.com"}],"homepage":"https://github.com/daveycodez/better-auth-instantdb","dist":{"shasum":"93457af7d63cada35ead354df61d49906833804e","tarball":"https://registry.npmjs.org/better-auth-instantdb/-/better-auth-instantdb-1.3.0.tgz","fileCount":68,"integrity":"sha512-6HCUlT6j1hcAvzjHWK/B5r5TWdORYq/mVUbYzSh0Kyva1vJOqQqxId8h5vCPEHwwiEBlFfTY7o2KkfXJxtbsIw==","signatures":[{"sig":"MEUCIGSmmzhZGt+UNvmyDqAI1OpwaMp9Jjbp+01lwZ8zhi1eAiEAykKY0s0iUXjeZoCosJdBD9GRBS+I4mv2FqUAaZ/tvdU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":332346},"type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./react":{"types":"./dist/react/index.d.ts","import":"./dist/react/index.js"}},"gitHead":"ebaebc4c39258e4dc00e4424332d139e0c4ad405","scripts":{"dev":"tsc --watch","build":"tsc"},"_npmUser":{"name":"daveycodez","email":"daveycodez@gmail.com"},"_npmVersion":"10.9.2","description":"Better Auth InstantDB Adapter","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.22.0","devDependencies":{"react":"^19.2.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/node":"^24.10.1","better-auth":"^1.3.34","@types/react":"^19.2.5","@instantdb/core":"^0.22.51","@instantdb/admin":"^0.22.51","@instantdb/react":"^0.22.51","@types/react-dom":"^19.2.3","@better-auth/core":"^1.3.34"},"peerDependencies":{"better-auth":">=1.3.0","@instantdb/admin":">=0.22.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"@instantdb/react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/better-auth-instantdb_1.3.0_1764975591362_0.8887194880761837","host":"s3://npm-registry-packages-npm-production"},"peerDependenciesOptional":{"react":">=18.0.0","react-dom":">=18.0.0","@instantdb/react":">=0.22.0"}},"1.3.1":{"name":"better-auth-instantdb","version":"1.3.1","keywords":["typescript","instantdb","better","better-auth","auth","authentication","adapter"],"author":{"name":"daveycodez"},"license":"MIT","_id":"better-auth-instantdb@1.3.1","maintainers":[{"name":"daveycodez","email":"daveycodez@gmail.com"}],"homepage":"https://github.com/daveycodez/better-auth-instantdb","dist":{"shasum":"71733665af504128596db6bb7865a0dbea9b7199","tarball":"https://registry.npmjs.org/better-auth-instantdb/-/better-auth-instantdb-1.3.1.tgz","fileCount":29,"integrity":"sha512-uuWUl7BuLeRdAkuD+zPHY1Qi5utkqDNTEmZ6qieOfPt8HuJPIfpQEXXmaZ9p5rg1K9fNgJWBMw0Kat70m3DPuw==","signatures":[{"sig":"MEYCIQDoxBBy+88+4neRTL0nTJE/IPiDB0qd1+KNRpo87ibXYgIhAIwUSU4psPqSvZ/AiF8JiZkzDIApTcLftbUkkLc2zh7o","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":163558},"type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./react":{"types":"./dist/react/index.d.ts","import":"./dist/react/index.js"}},"gitHead":"3410ca3896d326fea9e40a6234a4def07b13674d","scripts":{"dev":"tsc --watch","build":"tsc && vite build"},"_npmUser":{"name":"daveycodez","email":"daveycodez@gmail.com"},"_npmVersion":"10.9.4","description":"Better Auth InstantDB Adapter","directories":{},"_nodeVersion":"22.21.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.22.0","devDependencies":{"vite":"^7.3.0","react":"^19.2.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/node":"^24.10.1","better-auth":"^1.3.34","@types/react":"^19.2.5","@instantdb/core":"^0.22.51","vite-plugin-dts":"^4.5.4","@instantdb/admin":"^0.22.51","@instantdb/react":"^0.22.51","@types/react-dom":"^19.2.3","@better-auth/core":"^1.3.34"},"peerDependencies":{"better-auth":">=1.3.0","@instantdb/admin":">=0.22.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"@instantdb/react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/better-auth-instantdb_1.3.1_1765967513128_0.3460425317905895","host":"s3://npm-registry-packages-npm-production"},"peerDependenciesOptional":{"react":">=18.0.0","react-dom":">=18.0.0","@instantdb/react":">=0.22.0"}},"1.3.2":{"name":"better-auth-instantdb","version":"1.3.2","keywords":["typescript","instantdb","better","better-auth","auth","authentication","adapter"],"author":{"name":"daveycodez"},"license":"MIT","_id":"better-auth-instantdb@1.3.2","maintainers":[{"name":"daveycodez","email":"daveycodez@gmail.com"}],"homepage":"https://github.com/daveycodez/better-auth-instantdb","dist":{"shasum":"3ba8b96b349893482900ffe85337620cc7b08c2a","tarball":"https://registry.npmjs.org/better-auth-instantdb/-/better-auth-instantdb-1.3.2.tgz","fileCount":29,"integrity":"sha512-exC5E11FZrnL4x+8kPBKySgqnIRZfvy/E0of8wii74ogxBOhsoJjEfdsFFuca30JO0+IR3sHQLqhcd/wwAShWQ==","signatures":[{"sig":"MEYCIQC7aHVWw+owlceprnfWT51xfyijZ7pRsLn6v82IEJPmFgIhAKatQchffiyZZ6MavheVW0a0K9rogmGwSSVowBmeEz+H","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":164401},"type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./react":{"types":"./dist/react/index.d.ts","import":"./dist/react/index.js"}},"gitHead":"6cf555691b2a233f09f12dc631e4e6a8ddbac41d","scripts":{"dev":"tsc --watch","build":"tsc && vite build"},"_npmUser":{"name":"daveycodez","email":"daveycodez@gmail.com"},"_npmVersion":"10.9.2","description":"Better Auth InstantDB Adapter","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.22.0","devDependencies":{"vite":"^7.3.0","react":"^19.2.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/node":"^24.10.1","better-auth":"^1.3.34","@types/react":"^19.2.5","@instantdb/core":"^0.22.51","vite-plugin-dts":"^4.5.4","@instantdb/admin":"^0.22.51","@instantdb/react":"^0.22.51","@types/react-dom":"^19.2.3","@better-auth/core":"^1.3.34"},"peerDependencies":{"better-auth":">=1.3.0","@instantdb/admin":">=0.22.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"@instantdb/react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/better-auth-instantdb_1.3.2_1766191888468_0.5102865935394498","host":"s3://npm-registry-packages-npm-production"},"peerDependenciesOptional":{"react":">=18.0.0","react-dom":">=18.0.0","@instantdb/react":">=0.22.0"}},"1.3.3":{"name":"better-auth-instantdb","version":"1.3.3","keywords":["typescript","instantdb","better","better-auth","auth","authentication","adapter"],"author":{"name":"daveycodez"},"license":"MIT","_id":"better-auth-instantdb@1.3.3","maintainers":[{"name":"daveycodez","email":"daveycodez@gmail.com"}],"homepage":"https://github.com/daveycodez/better-auth-instantdb","dist":{"shasum":"3b5087e9eedec25d011fd6840295aec4bd3b6f63","tarball":"https://registry.npmjs.org/better-auth-instantdb/-/better-auth-instantdb-1.3.3.tgz","fileCount":29,"integrity":"sha512-A8uO/l/UVg+GcmBuEBXoyIJwIvuieJCSIaH84rbXI7aS9YBtbMhC16S27i/ShgjA0pU6K03lRx55FzXVbVrJ3Q==","signatures":[{"sig":"MEUCIGkL0WIRHLE59YABS3iGYZwR0G3LHXSI73Zs6OmMEGJkAiEA61sVrBYHBMeDm1OVnB8mvRjUy+vytcgeRnBVTFSNWp0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":161184},"type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./react":{"types":"./dist/react/index.d.ts","import":"./dist/react/index.js"}},"gitHead":"9e64f67a39c74bd2f474f5df6bef4da24fc52757","scripts":{"dev":"tsc --watch","build":"tsc && vite build"},"_npmUser":{"name":"daveycodez","email":"daveycodez@gmail.com"},"_npmVersion":"10.9.2","description":"Better Auth InstantDB Adapter","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.22.0","devDependencies":{"vite":"^7.3.0","react":"^19.2.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/node":"^24.10.1","better-auth":"^1.6.9","@types/react":"^19.2.5","@instantdb/core":"^0.22.51","vite-plugin-dts":"^4.5.4","@instantdb/admin":"^0.22.51","@instantdb/react":"^0.22.51","@types/react-dom":"^19.2.3","@better-auth/core":"^1.6.9"},"peerDependencies":{"better-auth":">=1.6.0","@instantdb/admin":">=0.22.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"@instantdb/react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/better-auth-instantdb_1.3.3_1778279733626_0.192152791126867","host":"s3://npm-registry-packages-npm-production"},"peerDependenciesOptional":{"react":">=18.0.0","react-dom":">=18.0.0","@instantdb/react":">=0.22.0"}},"1.3.4":{"name":"better-auth-instantdb","version":"1.3.4","keywords":["typescript","instantdb","better","better-auth","auth","authentication","adapter"],"author":{"name":"daveycodez"},"license":"MIT","_id":"better-auth-instantdb@1.3.4","maintainers":[{"name":"daveycodez","email":"daveycodez@gmail.com"}],"homepage":"https://github.com/daveycodez/better-auth-instantdb","dist":{"shasum":"3307f40b197090539e1788fc5943d712f8817880","tarball":"https://registry.npmjs.org/better-auth-instantdb/-/better-auth-instantdb-1.3.4.tgz","fileCount":29,"integrity":"sha512-xacu0bBkryexkbSR6N72eZxidIjuQGB2FBiGVOu/CvvPqwzdImVbnIXdKy+f1K5wocPcrDi1kpRfGhPcoH2BVQ==","signatures":[{"sig":"MEYCIQCXlByCh7V3BbYrrvyLu2PM86RbSEUpxyiY3tbWnP+gdwIhAKCTLgSj9ldtb4SlfqTf2g4rQx5QAg2U5/AMRosOwQ5q","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57005},"type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./react":{"types":"./dist/react/index.d.ts","import":"./dist/react/index.js"}},"gitHead":"a1ce398053b626b0ea3b06d95760ac60846fa727","scripts":{"dev":"tsc --watch","build":"tsc && vite build"},"_npmUser":{"name":"daveycodez","email":"daveycodez@gmail.com"},"_npmVersion":"10.9.2","description":"Better Auth InstantDB Adapter","directories":{},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.22.0","devDependencies":{"vite":"^7.3.0","react":"^19.2.0","react-dom":"^19.2.0","typescript":"^5.9.3","@types/node":"^24.10.1","better-auth":"^1.6.9","@types/react":"^19.2.5","@instantdb/core":"^0.22.51","vite-plugin-dts":"^4.5.4","@instantdb/admin":"^0.22.51","@instantdb/react":"^0.22.51","@types/react-dom":"^19.2.3","@better-auth/core":"^1.6.9"},"peerDependencies":{"better-auth":">=1.6.0","@instantdb/admin":">=0.22.0"},"peerDependenciesMeta":{"react":{"optional":true},"react-dom":{"optional":true},"@instantdb/react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/better-auth-instantdb_1.3.4_1785953193258_0.24669082556494404","host":"s3://npm-registry-packages-npm-production"},"peerDependenciesOptional":{"react":">=18.0.0","react-dom":">=18.0.0","@instantdb/react":">=0.22.0"}}},"time":{"created":"2025-12-05T22:59:51.285Z","modified":"2026-08-06T02:59:11.848Z","1.3.0":"2025-12-05T22:59:51.506Z","1.3.1":"2025-12-17T10:31:53.272Z","1.3.2":"2025-12-20T00:51:28.641Z","1.3.3":"2026-05-08T22:35:33.774Z","1.3.4":"2026-08-05T18:06:33.437Z"},"author":{"name":"daveycodez"},"license":"MIT","homepage":"https://github.com/daveycodez/better-auth-instantdb","keywords":["typescript","instantdb","better","better-auth","auth","authentication","adapter"],"description":"Better Auth InstantDB Adapter","maintainers":[{"email":"wingkwong.code@gmail.com","name":"wingkwong"},{"email":"daveycodez@gmail.com","name":"daveycodez"}],"readme":"# Better Auth InstantDB Adapter\n\nA seamless integration between [Better Auth](https://better-auth.com) and [InstantDB](https://www.instantdb.com) that allows you to use InstantDB as your authentication database.\n\n[Better Auth UI Integration](https://better-auth-ui.com/data/instantdb)\n\n- *Own Your Auth*\n\n𝕏 [@daveycodez](https://x.com/daveycodez)\n\n## Installation\n\n```bash\nbun add better-auth-instantdb@latest\n```\n\n## Features\n\n- 🔐 **Complete Authentication**: Leverage Better Auth's authentication features with InstantDB as your database\n- 🔄 **Session Sync**: Automatically synchronize auth sessions between Better Auth and InstantDB\n- 🛠️ **Customizable**: Configure the adapter to match your specific needs\n- 🧩 **Type-Safe**: Fully typed with TypeScript for improved developer experience\n\n## Usage\n\n### Basic Setup\n\nFirst you need to add the InstantDB Adapter to your Better Auth config.\n\n#### auth.ts\n```typescript\nimport { betterAuth } from \"better-auth\"\nimport { instantAdapter } from \"better-auth-instantdb\"\nimport { init } from \"@instantdb/admin\"\nimport schema from \"@/instant.schema\"\n\n// Create InstantDB admin client\nexport const adminDb = init({\n  schema,\n  appId: process.env.VITE_INSTANT_APP_ID as string,\n  adminToken: process.env.INSTANT_ADMIN_TOKEN,\n  useDateObjects: true\n})\n\n// Create Better Auth instance with InstantDB adapter\nexport const auth = betterAuth({\n  database: instantAdapter({\n    db: adminDb,\n    usePlural: true, // Optional: set to true if your schema uses plural table names\n    debugLogs: false  // Optional: set to true to see detailed logs\n  }),\n  // Other Better Auth configuration options\n  emailAndPassword: {\n    enabled: true\n  },\n})\n```\n\n### Client-Side Usage\n\nSynchronize authentication state between Better Auth and InstantDB:\n\n#### providers.tsx\n```typescript\nimport authClient from \"@/lib/auth-client\"\nimport { init } from \"@instantdb/react\"\nimport { useInstantAuth } from \"better-auth-instantdb\"\n\n// Initialize InstantDB client\nconst db = init({ \n    appId: process.env.NEXT_PUBLIC_INSTANT_APP_ID\n})\n\nexport function Providers({ children }) {\n  return (\n      <>\n        <InstantAuth db={db} authClient={authClient} persistent />\n\n        {children}\n      </>\n  )\n}\n```\n\n## InstantDB Schema and Permissions Setup\n\n⚠️ **Important**: You can now use Better Auth cli to generate InstantDB schema, but you must manually configure permissions, for now.\n\n### 1. Create Schema File\n\nRun the following command in terminal:\n\n```bash\nnpx @better-auth/cli generate\n```\n\n### 2. Create Permissions File\n\nCreate an `instant.perms.ts` file to secure your schema:\n\n```typescript\n// instant.perms.ts\nimport type { InstantRules } from \"@instantdb/react\";\n\nconst rules = {\n  // Prevent creation of new attributes without explicit schema changes\n  attrs: {\n    allow: {\n      $default: \"false\",\n    },\n  },\n  // Auth entities permissions\n  users: {\n    bind: [\"isOwner\", \"auth.id != null && auth.id == data.id\"],\n    allow: {\n      view: \"isOwner\",\n      create: \"false\",\n      delete: \"false\",\n      update: \"isOwner && (newData.email == data.email) && (newData.emailVerified == data.emailVerified) && (newData.createdAt == data.createdAt)\",\n    },\n  },\n  accounts: {\n    bind: [\"isOwner\", \"auth.id != null && auth.id == data.userId\"],\n    allow: {\n      view: \"isOwner\",\n      create: \"false\",\n      delete: \"false\",\n      update: \"false\",\n    },\n  },\n  sessions: {\n    bind: [\"isOwner\", \"auth.id != null && auth.id == data.userId\"],\n    allow: {\n      view: \"isOwner\",\n      create: \"false\",\n      delete: \"false\",\n      update: \"false\",\n    },\n  },\n  verifications: {\n    allow: {\n      $default: \"false\"\n    }\n  },\n  // Optional permissions (public profile example)\n  profiles: {\n    bind: [\"isOwner\", \"auth.id != null && auth.id == data.id\"],\n    allow: {\n      view: \"true\",\n      create: \"false\",\n      delete: \"false\",\n      update: \"isOwner\",\n    },\n  },\n  // Add your custom entity permissions here\n} satisfies InstantRules;\n\nexport default rules;\n```\n\n### 3. Push Schema and Permissions to InstantDB\n\nAfter creating these files, use the InstantDB CLI to push them to your app:\n\n```bash\n# Push schema\nnpx instant-cli@latest push schema\n\n# Push permissions\nnpx instant-cli@latest push perms\n```\n\n### 4. Initialize InstantDB with Your Schema\n\nUpdate your client-side InstantDB initialization to use your schema:\n\n#### /database/instant.ts\n```typescript\nimport { init } from \"@instantdb/react\"\nimport schema from \"../../instant.schema\"\n\nexport const db = init({\n    appId: process.env.NEXT_PUBLIC_INSTANT_APP_ID,\n    schema\n})\n```\n\n## API Reference\n\n### `instantAdapter(options)`\n\nCreates an adapter that allows Better Auth to use InstantDB as its database.\n\n#### Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `db` | `InstantAdminDatabase` | (required) | An InstantDB admin client instance |\n| `usePlural` | `boolean` | `true` | Set to `false` if your schema uses singular table names |\n| `debugLogs` | `boolean` | `false` | Set to `true` to enable detailed logging |\n\n### `useInstantAuth({ db, useSession })`\n\nA React hook that synchronizes authentication state between Better Auth and InstantDB.\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `db` | `InstantReactWebDatabase` | An InstantDB client instance |\n| `authClient` | `AuthClient` | The `authClient` from Better Auth |\n| `persistent` | `boolean?` | Whether to enable offline persistence for session |\n\n## License\n\nMIT\n","readmeFilename":"README.md"}