[{"data":1,"prerenderedAt":566},["ShallowReactive",2],{"navigation_docs":3,"-getting-started-schema-generation":152,"-getting-started-schema-generation-surround":561},[4,42,68,110,131],{"title":5,"path":6,"stem":7,"children":8,"icon":11},"Getting Started","\u002Fgetting-started","1.getting-started\u002F0.index",[9,12,17,22,27,32,37],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-sparkles",{"title":13,"path":14,"stem":15,"icon":16},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F1.installation","i-lucide-download",{"title":18,"path":19,"stem":20,"icon":21},"Configuration","\u002Fgetting-started\u002Fconfiguration","1.getting-started\u002F2.configuration","i-lucide-settings",{"title":23,"path":24,"stem":25,"icon":26},"Client Setup","\u002Fgetting-started\u002Fclient-setup","1.getting-started\u002F3.client-setup","i-lucide-monitor",{"title":28,"path":29,"stem":30,"icon":31},"Type Augmentation","\u002Fgetting-started\u002Ftype-augmentation","1.getting-started\u002F4.type-augmentation","i-lucide-type",{"title":33,"path":34,"stem":35,"icon":36},"Schema Generation (NuxtHub)","\u002Fgetting-started\u002Fschema-generation","1.getting-started\u002F5.schema-generation","i-lucide-database",{"title":38,"path":39,"stem":40,"icon":41},"How It Works","\u002Fgetting-started\u002Fhow-it-works","1.getting-started\u002F6.how-it-works","i-lucide-workflow",{"title":43,"path":44,"stem":45,"children":46,"page":67},"Core Concepts","\u002Fcore-concepts","2.core-concepts",[47,51,55,59,63],{"title":48,"path":49,"stem":50},"serverAuth()","\u002Fcore-concepts\u002Fserver-auth","2.core-concepts\u002F1.server-auth",{"title":52,"path":53,"stem":54},"Sessions","\u002Fcore-concepts\u002Fsessions","2.core-concepts\u002F2.sessions",{"title":56,"path":57,"stem":58},"Route Protection","\u002Fcore-concepts\u002Froute-protection","2.core-concepts\u002F3.route-protection",{"title":60,"path":61,"stem":62},"Auto‑Imports and Aliases","\u002Fcore-concepts\u002Fauto-imports-aliases","2.core-concepts\u002F4.auto-imports-aliases",{"title":64,"path":65,"stem":66},"Security & Caveats","\u002Fcore-concepts\u002Fsecurity-caveats","2.core-concepts\u002F5.security-caveats",false,{"title":69,"path":70,"stem":71,"children":72,"page":67},"Guides","\u002Fguides","3.guides",[73,77,81,85,89,94,98,102,106],{"title":74,"path":75,"stem":76},"Role‑Based Access","\u002Fguides\u002Frole-based-access","3.guides\u002F1.role-based-access",{"title":78,"path":79,"stem":80},"OAuth Providers","\u002Fguides\u002Foauth-providers","3.guides\u002F2.oauth-providers",{"title":82,"path":83,"stem":84},"Custom Database","\u002Fguides\u002Fcustom-database","3.guides\u002F3.custom-database",{"title":86,"path":87,"stem":88},"Database-less Mode","\u002Fguides\u002Fdatabase-less-mode","3.guides\u002F4.database-less-mode",{"title":90,"path":91,"stem":92,"icon":93},"External Auth Backend","\u002Fguides\u002Fexternal-auth-backend","3.guides\u002F5.external-auth-backend","i-lucide-server",{"title":95,"path":96,"stem":97},"Migrating from nuxt-auth-utils","\u002Fguides\u002Fmigrate-from-nuxt-auth-utils","3.guides\u002F6.migrate-from-nuxt-auth-utils",{"title":99,"path":100,"stem":101},"Two-Factor Authentication (TOTP + Backup Codes)","\u002Fguides\u002Ftwo-factor-auth","3.guides\u002F7.two-factor-auth",{"title":103,"path":104,"stem":105},"Testing","\u002Fguides\u002Ftesting","3.guides\u002F8.testing",{"title":107,"path":108,"stem":109},"Production Deployment","\u002Fguides\u002Fproduction-deployment","3.guides\u002F9.production-deployment",{"title":111,"path":112,"stem":113,"children":114,"page":67},"Integrations","\u002Fintegrations","4.integrations",[115,119,123,127],{"title":116,"path":117,"stem":118},"NuxtHub","\u002Fintegrations\u002Fnuxthub","4.integrations\u002F1.nuxthub",{"title":120,"path":121,"stem":122},"DevTools","\u002Fintegrations\u002Fdevtools","4.integrations\u002F2.devtools",{"title":124,"path":125,"stem":126},"Convex","\u002Fintegrations\u002Fconvex","4.integrations\u002F3.convex",{"title":128,"path":129,"stem":130},"i18n","\u002Fintegrations\u002Fi18n","4.integrations\u002F4.i18n",{"title":132,"path":133,"stem":134,"children":135,"page":67},"API Reference","\u002Fapi","5.api",[136,140,144,148],{"title":137,"path":138,"stem":139},"Composables","\u002Fapi\u002Fcomposables","5.api\u002F1.composables",{"title":141,"path":142,"stem":143},"Server Utilities","\u002Fapi\u002Fserver-utils","5.api\u002F2.server-utils",{"title":145,"path":146,"stem":147},"Components","\u002Fapi\u002Fcomponents","5.api\u002F3.components",{"title":149,"path":150,"stem":151},"Types","\u002Fapi\u002Ftypes","5.api\u002F4.types",{"id":153,"title":154,"body":155,"description":554,"extension":555,"links":556,"meta":557,"navigation":558,"path":34,"seo":559,"stem":35,"__hash__":560},"docs\u002F1.getting-started\u002F5.schema-generation.md","Schema Generation",{"type":156,"value":157,"toc":548},"minimark",[158,223,232,242,252,257,272,314,321,325,331,347,353,429,433,439,497,501,504,521,528,537,544],[159,160,161],"code-collapse",{},[162,163,169],"pre",{"className":164,"code":165,"filename":166,"language":167,"meta":168,"style":168},"language-txt shiki shiki-themes one-light synthwave-84 synthwave-84","Set up auto schema generation for @nuxtjs\u002Fbetter-auth with NuxtHub.\n\n- Requires NuxtHub integration — the module generates Drizzle ORM schemas at build time\n- Supports sqlite (default), postgresql, and mysql dialects via `hub.db.dialect` in `nuxt.config.ts`\n- The module reads `server\u002Fauth.config.ts` plugins to determine required tables (user, session, account, verification + plugin tables)\n- After adding\u002Fremoving plugins: restart the dev server to regenerate schemas\n- For production (Cloudflare D1): run `npx nuxt db migrate`\n- No manual Drizzle schema writing needed for auth tables\n","Prompt","txt","",[170,171,172,180,187,193,199,205,211,217],"code",{"__ignoreMap":168},[173,174,177],"span",{"class":175,"line":176},"line",1,[173,178,179],{},"Set up auto schema generation for @nuxtjs\u002Fbetter-auth with NuxtHub.\n",[173,181,183],{"class":175,"line":182},2,[173,184,186],{"emptyLinePlaceholder":185},true,"\n",[173,188,190],{"class":175,"line":189},3,[173,191,192],{},"- Requires NuxtHub integration — the module generates Drizzle ORM schemas at build time\n",[173,194,196],{"class":175,"line":195},4,[173,197,198],{},"- Supports sqlite (default), postgresql, and mysql dialects via `hub.db.dialect` in `nuxt.config.ts`\n",[173,200,202],{"class":175,"line":201},5,[173,203,204],{},"- The module reads `server\u002Fauth.config.ts` plugins to determine required tables (user, session, account, verification + plugin tables)\n",[173,206,208],{"class":175,"line":207},6,[173,209,210],{},"- After adding\u002Fremoving plugins: restart the dev server to regenerate schemas\n",[173,212,214],{"class":175,"line":213},7,[173,215,216],{},"- For production (Cloudflare D1): run `npx nuxt db migrate`\n",[173,218,220],{"class":175,"line":219},8,[173,221,222],{},"- No manual Drizzle schema writing needed for auth tables\n",[224,225,226,227,231],"p",{},"Use this page when you are using ",[228,229],"brand-badge",{"name":230},"nuxthub"," and want the module to generate auth tables from your Better Auth configuration.",[233,234,235,236,238,239,241],"note",{},"This feature requires ",[228,237],{"name":230},". See ",[228,240],{"name":230,"to":117}," for setup.",[224,243,244,245,247,248,251],{},"Better Auth requires tables for users, sessions, accounts. This module creates them automatically with ",[228,246],{"name":230}," and ",[228,249],{"name":250},"drizzle"," ORM.",[253,254,256],"h2",{"id":255},"how-it-works","How it works",[224,258,259,260,263,264,267,268,271],{},"The module analyzes your ",[170,261,262],{},"server\u002Fauth.config.ts"," at build time to determine which tables are required by your core configuration and enabled plugins (e.g., ",[170,265,266],{},"twoFactor",", ",[170,269,270],{},"passkey",").",[273,274,275,287,305],"ol",{},[276,277,278,282,283,286],"li",{},[279,280,281],"strong",{},"Analysis",": Reads ",[170,284,285],{},"plugins"," from your config.",[276,288,289,292,293,295,296,267,299,267,302,271],{},[279,290,291],{},"Generation",": Generates a ",[228,294],{"name":250}," schema file corresponding to your database dialect (",[228,297],{"name":298},"sqlite",[228,300],{"name":301},"postgresql",[228,303],{"name":304},"mysql",[276,306,307,310,311,313],{},[279,308,309],{},"Integration",": Automatically injects this schema into ",[228,312],{"name":230},"'s database configuration.",[315,316,317,318,320],"tip",{},"You do not need to manually write ",[228,319],{"name":250}," schemas for authentication tables.",[253,322,324],{"id":323},"supported-dialects","Supported Dialects",[224,326,327,328,330],{},"The module supports all dialects compatible with ",[228,329],{"name":230},":",[332,333,334,339,343],"ul",{},[276,335,336,338],{},[170,337,298],{}," (Default)",[276,340,341],{},[170,342,301],{},[276,344,345],{},[170,346,304],{},[224,348,349,350,330],{},"Ensure you have configured the dialect in ",[170,351,352],{},"nuxt.config.ts",[162,354,358],{"className":355,"code":356,"filename":352,"language":357,"meta":168,"style":168},"language-ts shiki shiki-themes one-light synthwave-84 synthwave-84","export default defineNuxtConfig({\n  hub: {\n    db: {\n      dialect: 'postgresql' \u002F\u002F or 'sqlite', 'mysql'\n    }\n  }\n})\n","ts",[170,359,360,378,390,399,414,419,424],{"__ignoreMap":168},[173,361,362,366,370,374],{"class":175,"line":176},[173,363,365],{"class":364},"sqe1H","export",[173,367,369],{"class":368},"sKg8T"," default",[173,371,373],{"class":372},"sfT9l"," defineNuxtConfig",[173,375,377],{"class":376},"s17Py","({\n",[173,379,380,384,387],{"class":175,"line":182},[173,381,383],{"class":382},"sYvLG","  hub",[173,385,330],{"class":386},"sVnqq",[173,388,389],{"class":376}," {\n",[173,391,392,395,397],{"class":175,"line":189},[173,393,394],{"class":382},"    db",[173,396,330],{"class":386},[173,398,389],{"class":376},[173,400,401,404,406,410],{"class":175,"line":195},[173,402,403],{"class":382},"      dialect",[173,405,330],{"class":386},[173,407,409],{"class":408},"sPAZv"," 'postgresql'",[173,411,413],{"class":412},"st7cf"," \u002F\u002F or 'sqlite', 'mysql'\n",[173,415,416],{"class":175,"line":201},[173,417,418],{"class":376},"    }\n",[173,420,421],{"class":175,"line":207},[173,422,423],{"class":376},"  }\n",[173,425,426],{"class":175,"line":213},[173,427,428],{"class":376},"})\n",[253,430,432],{"id":431},"workflow","Workflow",[224,434,435,436,438],{},"When you add a new plugin that requires database tables (e.g., adding ",[170,437,266],{},"):",[273,440,441,447,450,453,459],{},[276,442,443,444,446],{},"Update ",[170,445,262],{},".",[276,448,449],{},"Restart your development server.",[276,451,452],{},"The module regenerates the schema.",[276,454,455,456,458],{},"If using ",[228,457],{"name":230}," local development, the tables are ready.",[276,460,461,464,467,468,470,471,438,474],{},[279,462,463],{},"Deploy with migrations:",[465,466],"br",{},"For local development, migrations run automatically when you start the dev server.",[465,469],{},"For production (",[228,472],{"name":473},"cloudflare-d1",[162,475,479],{"className":476,"code":477,"language":478,"meta":168,"style":168},"language-bash shiki shiki-themes one-light synthwave-84 synthwave-84","npx nuxt db migrate\n","bash",[170,480,481],{"__ignoreMap":168},[173,482,483,487,491,494],{"class":175,"line":176},[173,484,486],{"class":485},"siqUp","npx",[173,488,490],{"class":489},"sI3kV"," nuxt",[173,492,493],{"class":489}," db",[173,495,496],{"class":489}," migrate\n",[253,498,500],{"id":499},"when-not-to-use-this","When not to use this",[224,502,503],{},"Do not rely on this flow if:",[332,505,506,511,518],{},[276,507,508,509],{},"you are not using ",[228,510],{"name":230},[276,512,513,514,517],{},"you are in ",[170,515,516],{},"clientOnly"," mode",[276,519,520],{},"you manage Better Auth tables with a separate adapter and migration pipeline",[224,522,523,524,446],{},"In those cases, use ",[525,526,527],"a",{"href":83},"custom database setup",[529,530,533,534,536],"callout",{":external":531,"to":532},"true","https:\u002F\u002Fhub.nuxt.com\u002Fdocs\u002Fgetting-started\u002Fdeploy","See ",[228,535],{"name":230,":unlinked":531}," deployment documentation.",[538,539,540,543],"warning",{},[279,541,542],{},"Restart Required",": Because schema generation happens at build\u002Fmodule-setup time, you must restart the dev server after adding or removing plugins that affect the database structure.",[545,546,547],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sqe1H, html code.shiki .sqe1H{--shiki-light:#A626A4;--shiki-default:#FEDE5D;--shiki-dark:#FEDE5D}html pre.shiki code .sKg8T, html code.shiki .sKg8T{--shiki-light:#E45649;--shiki-default:#FEDE5D;--shiki-dark:#FEDE5D}html pre.shiki code .sfT9l, html code.shiki .sfT9l{--shiki-light:#4078F2;--shiki-default:#36F9F6;--shiki-dark:#36F9F6}html pre.shiki code .s17Py, html code.shiki .s17Py{--shiki-light:#383A42;--shiki-default:#BBBBBB;--shiki-dark:#BBBBBB}html pre.shiki code .sYvLG, html code.shiki .sYvLG{--shiki-light:#E45649;--shiki-default:#FF7EDB;--shiki-dark:#FF7EDB}html pre.shiki code .sVnqq, html code.shiki .sVnqq{--shiki-light:#0184BC;--shiki-default:#B6B1B1;--shiki-dark:#B6B1B1}html pre.shiki code .sPAZv, html code.shiki .sPAZv{--shiki-light:#50A14F;--shiki-default:#FF8B39;--shiki-dark:#FF8B39}html pre.shiki code .st7cf, html code.shiki .st7cf{--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-default:#848BBD;--shiki-default-font-style:italic;--shiki-dark:#848BBD;--shiki-dark-font-style:italic}html pre.shiki code .siqUp, html code.shiki .siqUp{--shiki-light:#4078F2;--shiki-default:#FE4450;--shiki-dark:#FE4450}html pre.shiki code .sI3kV, html code.shiki .sI3kV{--shiki-light:#50A14F;--shiki-default:#BBBBBB;--shiki-dark:#BBBBBB}",{"title":168,"searchDepth":182,"depth":182,"links":549},[550,551,552,553],{"id":255,"depth":182,"text":256},{"id":323,"depth":182,"text":324},{"id":431,"depth":182,"text":432},{"id":499,"depth":182,"text":500},"Auto-generate Drizzle ORM schemas for Better Auth tables when using NuxtHub.","md",null,{},{"title":33,"icon":36},{"title":154,"description":554},"XA-Zh-Cz0iDBPfb8puJ0-ukQ9YHe5PeLXSsalU0mxZk",[562,564],{"title":28,"path":29,"stem":30,"description":563,"icon":31,"children":-1},"Learn how the module automatically infers types from your configuration.",{"title":38,"path":39,"stem":40,"description":565,"icon":41,"children":-1},"Understand the architecture after completing setup.",1788606328956]