[{"data":1,"prerenderedAt":683,"buildId":684},["ShallowReactive",2],{"-getting-started":3,"-getting-started-surround":474,"navigation_docs":480},{"id":4,"title":5,"body":6,"description":464,"extension":465,"links":466,"meta":467,"navigation":468,"path":470,"seo":471,"stem":472,"__hash__":473},"docs\u002F1.getting-started\u002F0.index.md","Introduction",{"type":7,"value":8,"toc":451},"minimark",[9,13,16,33,53,58,61,95,99,114,118,373,377,380,398,408,412,447],[10,11,12],"p",{},"Use this page when you want the fastest path to a working Nuxt setup.",[10,14,15],{},"This quickstart assumes:",[17,18,19,23,30],"ul",{},[20,21,22],"li",{},"you want the default full-mode setup",[20,24,25,26],{},"you are using ",[27,28,29],"code",{},"pnpm",[20,31,32],{},"you want a local login flow working before you customize providers or plugins",[10,34,35,36,41,42,47,48,52],{},"If you already know you need a different architecture, jump to ",[37,38],"brand-badge",{"name":39,"to":40},"nuxthub","\u002Fintegrations\u002Fnuxthub",", ",[43,44,46],"a",{"href":45},"\u002Fguides\u002Fcustom-database","custom database",", or ",[43,49,51],{"href":50},"\u002Fguides\u002Fexternal-auth-backend","external auth backend",".",[54,55,57],"h2",{"id":56},"what-you-will-end-up-with","What you will end up with",[10,59,60],{},"After this guide you should have:",[17,62,63,72,78,88],{},[20,64,65,68,69],{},[27,66,67],{},"server\u002Fauth.config.ts"," and ",[27,70,71],{},"app\u002Fauth.config.ts",[20,73,74,75],{},"Better Auth handlers mounted at ",[27,76,77],{},"\u002Fapi\u002Fauth\u002F*",[20,79,80,81,84,85],{},"a valid auth secret: ",[27,82,83],{},"NUXT_APP_SECRET"," on Nuxt 4.6+, or ",[27,86,87],{},"NUXT_BETTER_AUTH_SECRET",[20,89,90,91,94],{},"a reactive ",[27,92,93],{},"useUserSession()"," composable in your app",[54,96,98],{"id":97},"before-you-begin","Before you begin",[17,100,101,108],{},[20,102,103,104,107],{},"a local ",[27,105,106],{},".env"," file",[20,109,110,111],{},"a development server you can start with ",[27,112,113],{},"pnpm dev",[54,115,117],{"id":116},"quickstart","Quickstart",[119,120,121,126,157,161,167,204,225,229,317,321,357,361],"steps",{},[122,123,125],"h3",{"id":124},"install-the-module","Install the module",[127,128,133],"pre",{"className":129,"code":130,"language":131,"meta":132,"style":132},"language-bash shiki shiki-themes one-light synthwave-84 synthwave-84","npx nuxi module add @nuxtjs\u002Fbetter-auth\n","bash","",[27,134,135],{"__ignoreMap":132},[136,137,140,144,148,151,154],"span",{"class":138,"line":139},"line",1,[136,141,143],{"class":142},"siqUp","npx",[136,145,147],{"class":146},"sI3kV"," nuxi",[136,149,150],{"class":146}," module",[136,152,153],{"class":146}," add",[136,155,156],{"class":146}," @nuxtjs\u002Fbetter-auth\n",[122,158,160],{"id":159},"add-your-secret","Add your secret",[10,162,163,164,166],{},"Create or update ",[27,165,106],{},":",[127,168,172],{"className":169,"code":170,"filename":106,"language":171,"meta":132,"style":132},"language-ini shiki shiki-themes one-light synthwave-84 synthwave-84","# Nuxt 4.6 and newer\nNUXT_APP_SECRET=\"replace-with-a-random-32-character-secret\"\n\n# Nuxt 4.5 and older\n# NUXT_BETTER_AUTH_SECRET=\"replace-with-a-random-32-character-secret\"\n","ini",[27,173,174,179,185,192,198],{"__ignoreMap":132},[136,175,176],{"class":138,"line":139},[136,177,178],{},"# Nuxt 4.6 and newer\n",[136,180,182],{"class":138,"line":181},2,[136,183,184],{},"NUXT_APP_SECRET=\"replace-with-a-random-32-character-secret\"\n",[136,186,188],{"class":138,"line":187},3,[136,189,191],{"emptyLinePlaceholder":190},true,"\n",[136,193,195],{"class":138,"line":194},4,[136,196,197],{},"# Nuxt 4.5 and older\n",[136,199,201],{"class":138,"line":200},5,[136,202,203],{},"# NUXT_BETTER_AUTH_SECRET=\"replace-with-a-random-32-character-secret\"\n",[10,205,206,207,210,211,41,213,216,217,220,221,224],{},"Use a high-entropy value. On Nuxt 4.6+, the module derives its auth secret from Nuxt's ",[27,208,209],{},"appSecret"," when no auth secret is configured. ",[27,212,87],{},[27,214,215],{},"BETTER_AUTH_SECRET",", and Better Auth's versioned ",[27,218,219],{},"BETTER_AUTH_SECRETS","\u002F",[27,222,223],{},"secrets"," configuration override it, and one of them is required on older Nuxt versions.",[122,226,228],{"id":227},"create-the-server-config","Create the server config",[127,230,234],{"className":231,"code":232,"filename":67,"language":233,"meta":132,"style":132},"language-ts shiki shiki-themes one-light synthwave-84 synthwave-84","import { defineServerAuth } from '@nuxtjs\u002Fbetter-auth\u002Fconfig'\n\nexport default defineServerAuth({\n  emailAndPassword: {\n    enabled: true,\n  },\n})\n","ts",[27,235,236,260,264,280,291,305,311],{"__ignoreMap":132},[136,237,238,242,246,250,253,256],{"class":138,"line":139},[136,239,241],{"class":240},"sqe1H","import",[136,243,245],{"class":244},"s17Py"," { ",[136,247,249],{"class":248},"sYvLG","defineServerAuth",[136,251,252],{"class":244}," } ",[136,254,255],{"class":240},"from",[136,257,259],{"class":258},"sPAZv"," '@nuxtjs\u002Fbetter-auth\u002Fconfig'\n",[136,261,262],{"class":138,"line":181},[136,263,191],{"emptyLinePlaceholder":190},[136,265,266,269,273,277],{"class":138,"line":187},[136,267,268],{"class":240},"export",[136,270,272],{"class":271},"sKg8T"," default",[136,274,276],{"class":275},"sfT9l"," defineServerAuth",[136,278,279],{"class":244},"({\n",[136,281,282,285,288],{"class":138,"line":194},[136,283,284],{"class":248},"  emailAndPassword",[136,286,166],{"class":287},"sVnqq",[136,289,290],{"class":244}," {\n",[136,292,293,296,298,302],{"class":138,"line":200},[136,294,295],{"class":248},"    enabled",[136,297,166],{"class":287},[136,299,301],{"class":300},"s3ZNE"," true",[136,303,304],{"class":244},",\n",[136,306,308],{"class":138,"line":307},6,[136,309,310],{"class":244},"  },\n",[136,312,314],{"class":138,"line":313},7,[136,315,316],{"class":244},"})\n",[122,318,320],{"id":319},"create-the-client-config","Create the client config",[127,322,324],{"className":231,"code":323,"filename":71,"language":233,"meta":132,"style":132},"import { defineClientAuth } from '@nuxtjs\u002Fbetter-auth\u002Fconfig'\n\nexport default defineClientAuth({})\n",[27,325,326,341,345],{"__ignoreMap":132},[136,327,328,330,332,335,337,339],{"class":138,"line":139},[136,329,241],{"class":240},[136,331,245],{"class":244},[136,333,334],{"class":248},"defineClientAuth",[136,336,252],{"class":244},[136,338,255],{"class":240},[136,340,259],{"class":258},[136,342,343],{"class":138,"line":181},[136,344,191],{"emptyLinePlaceholder":190},[136,346,347,349,351,354],{"class":138,"line":187},[136,348,268],{"class":240},[136,350,272],{"class":271},[136,352,353],{"class":275}," defineClientAuth",[136,355,356],{"class":244},"({})\n",[122,358,360],{"id":359},"start-nuxt","Start Nuxt",[127,362,364],{"className":129,"code":363,"language":131,"meta":132,"style":132},"pnpm dev\n",[27,365,366],{"__ignoreMap":132},[136,367,368,370],{"class":138,"line":139},[136,369,29],{"class":142},[136,371,372],{"class":146}," dev\n",[54,374,376],{"id":375},"verify-the-result","Verify the result",[10,378,379],{},"Check these success signals:",[17,381,382,385,390,395],{},[20,383,384],{},"your app starts without auth-related module errors",[20,386,387,389],{},[27,388,77],{}," routes are registered",[20,391,392,394],{},[27,393,93],{}," is available in a page or component",[20,396,397],{},"the generated config files match your project structure",[10,399,400,401,404,405,52],{},"If you use a custom ",[27,402,403],{},"srcDir",", the client config lives there instead of ",[27,406,407],{},"app\u002F",[54,409,411],{"id":410},"next-steps","Next steps",[413,414,415,423,431,439],"ol",{},[20,416,417,418,422],{},"Follow ",[43,419,421],{"href":420},"\u002Fgetting-started\u002Finstallation","installation"," for the complete setup checklist.",[20,424,425,426,430],{},"Read ",[43,427,429],{"href":428},"\u002Fgetting-started\u002Fconfiguration","configuration"," before adding providers or plugins.",[20,432,433,434,438],{},"Set up ",[43,435,437],{"href":436},"\u002Fgetting-started\u002Fclient-setup","client usage"," in your pages and forms.",[20,440,441,442,446],{},"Add ",[43,443,445],{"href":444},"\u002Fcore-concepts\u002Froute-protection","route protection"," once the login flow works.",[448,449,450],"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 .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}html pre.shiki code .sqe1H, html code.shiki .sqe1H{--shiki-light:#A626A4;--shiki-default:#FEDE5D;--shiki-dark:#FEDE5D}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 .sPAZv, html code.shiki .sPAZv{--shiki-light:#50A14F;--shiki-default:#FF8B39;--shiki-dark:#FF8B39}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 .sVnqq, html code.shiki .sVnqq{--shiki-light:#0184BC;--shiki-default:#B6B1B1;--shiki-dark:#B6B1B1}html pre.shiki code .s3ZNE, html code.shiki .s3ZNE{--shiki-light:#986801;--shiki-default:#F97E72;--shiki-dark:#F97E72}",{"title":132,"searchDepth":181,"depth":181,"links":452},[453,454,455,462,463],{"id":56,"depth":181,"text":57},{"id":97,"depth":181,"text":98},{"id":116,"depth":181,"text":117,"children":456},[457,458,459,460,461],{"id":124,"depth":187,"text":125},{"id":159,"depth":187,"text":160},{"id":227,"depth":187,"text":228},{"id":319,"depth":187,"text":320},{"id":359,"depth":187,"text":360},{"id":375,"depth":181,"text":376},{"id":410,"depth":181,"text":411},"Nuxt Better Auth integrates Better Auth with Nuxt for route protection, session management, and schema generation.","md",null,{},{"icon":469},"i-lucide-sparkles","\u002Fgetting-started",{"title":5,"description":464},"1.getting-started\u002F0.index","jzsGXfuJM4lFbN7dYgbsIv1BH_2xZq55U4Oor6X7nlY",[466,475],{"title":476,"path":420,"stem":477,"description":478,"icon":479,"children":-1},"Installation","1.getting-started\u002F1.installation","Learn how to add Nuxt Better Auth to your Nuxt project.","i-lucide-download",[481,509,534,579,603,624],{"title":482,"path":470,"stem":472,"children":483,"icon":469},"Getting Started",[484,485,486,490,494,499,504],{"title":5,"path":470,"stem":472,"icon":469},{"title":476,"path":420,"stem":477,"icon":479},{"title":487,"path":428,"stem":488,"icon":489},"Configuration","1.getting-started\u002F2.configuration","i-lucide-settings",{"title":491,"path":436,"stem":492,"icon":493},"Client Setup","1.getting-started\u002F3.client-setup","i-lucide-monitor",{"title":495,"path":496,"stem":497,"icon":498},"Type Augmentation","\u002Fgetting-started\u002Ftype-augmentation","1.getting-started\u002F4.type-augmentation","i-lucide-type",{"title":500,"path":501,"stem":502,"icon":503},"Schema Generation (NuxtHub)","\u002Fgetting-started\u002Fschema-generation","1.getting-started\u002F5.schema-generation","i-lucide-database",{"title":505,"path":506,"stem":507,"icon":508},"How It Works","\u002Fgetting-started\u002Fhow-it-works","1.getting-started\u002F6.how-it-works","i-lucide-workflow",{"title":510,"path":511,"stem":512,"children":513,"page":533},"Core Concepts","\u002Fcore-concepts","2.core-concepts",[514,518,522,525,529],{"title":515,"path":516,"stem":517},"serverAuth()","\u002Fcore-concepts\u002Fserver-auth","2.core-concepts\u002F1.server-auth",{"title":519,"path":520,"stem":521},"Sessions","\u002Fcore-concepts\u002Fsessions","2.core-concepts\u002F2.sessions",{"title":523,"path":444,"stem":524},"Route Protection","2.core-concepts\u002F3.route-protection",{"title":526,"path":527,"stem":528},"Auto‑Imports and Aliases","\u002Fcore-concepts\u002Fauto-imports-aliases","2.core-concepts\u002F4.auto-imports-aliases",{"title":530,"path":531,"stem":532},"Security & Caveats","\u002Fcore-concepts\u002Fsecurity-caveats","2.core-concepts\u002F5.security-caveats",false,{"title":535,"path":536,"stem":537,"children":538,"page":533},"Guides","\u002Fguides","3.guides",[539,543,548,552,555,559,563,567,571,575],{"title":540,"path":541,"stem":542},"Role‑Based Access","\u002Fguides\u002Frole-based-access","3.guides\u002F1.role-based-access",{"title":544,"path":545,"stem":546,"icon":547},"Setup diagnostics","\u002Fguides\u002Fdiagnostics","3.guides\u002F10.diagnostics","i-lucide-circle-alert",{"title":549,"path":550,"stem":551},"OAuth Providers","\u002Fguides\u002Foauth-providers","3.guides\u002F2.oauth-providers",{"title":553,"path":45,"stem":554},"Custom Database","3.guides\u002F3.custom-database",{"title":556,"path":557,"stem":558},"Database-less Mode","\u002Fguides\u002Fdatabase-less-mode","3.guides\u002F4.database-less-mode",{"title":560,"path":50,"stem":561,"icon":562},"External Auth Backend","3.guides\u002F5.external-auth-backend","i-lucide-server",{"title":564,"path":565,"stem":566},"Migrating from nuxt-auth-utils","\u002Fguides\u002Fmigrate-from-nuxt-auth-utils","3.guides\u002F6.migrate-from-nuxt-auth-utils",{"title":568,"path":569,"stem":570},"Two-Factor Authentication (TOTP + Backup Codes)","\u002Fguides\u002Ftwo-factor-auth","3.guides\u002F7.two-factor-auth",{"title":572,"path":573,"stem":574},"Testing","\u002Fguides\u002Ftesting","3.guides\u002F8.testing",{"title":576,"path":577,"stem":578},"Production Deployment","\u002Fguides\u002Fproduction-deployment","3.guides\u002F9.production-deployment",{"title":580,"path":581,"stem":582,"children":583,"page":533},"Integrations","\u002Fintegrations","4.integrations",[584,587,591,595,599],{"title":585,"path":40,"stem":586},"NuxtHub","4.integrations\u002F1.nuxthub",{"title":588,"path":589,"stem":590},"DevTools","\u002Fintegrations\u002Fdevtools","4.integrations\u002F2.devtools",{"title":592,"path":593,"stem":594},"Convex","\u002Fintegrations\u002Fconvex","4.integrations\u002F3.convex",{"title":596,"path":597,"stem":598},"i18n","\u002Fintegrations\u002Fi18n","4.integrations\u002F4.i18n",{"title":600,"path":601,"stem":602},"MCP","\u002Fintegrations\u002Fmcp","4.integrations\u002F5.mcp",{"title":604,"path":605,"stem":606,"children":607,"page":533},"API Reference","\u002Fapi","5.api",[608,612,616,620],{"title":609,"path":610,"stem":611},"Composables","\u002Fapi\u002Fcomposables","5.api\u002F1.composables",{"title":613,"path":614,"stem":615},"Server Utilities","\u002Fapi\u002Fserver-utils","5.api\u002F2.server-utils",{"title":617,"path":618,"stem":619},"Components","\u002Fapi\u002Fcomponents","5.api\u002F3.components",{"title":621,"path":622,"stem":623},"Types","\u002Fapi\u002Ftypes","5.api\u002F4.types",{"title":625,"path":626,"stem":627,"children":628,"icon":547},"Errors","\u002Ferrors","6.errors\u002F0.index",[629,631,635,639,643,647,651,655,659,663,667,671,675,679],{"title":630,"path":626,"stem":627},"Overview",{"title":632,"path":633,"stem":634},"Better Auth CLI is not installed","\u002Ferrors\u002Fnuxt-auth-cli-missing","6.errors\u002Fnuxt-auth-cli-missing",{"title":636,"path":637,"stem":638},"Better Auth CLI version does not match better-auth","\u002Ferrors\u002Fnuxt-auth-cli-version-mismatch","6.errors\u002Fnuxt-auth-cli-version-mismatch",{"title":640,"path":641,"stem":642},"Auth configuration failed to load","\u002Ferrors\u002Fnuxt-auth-config-load-failed","6.errors\u002Fnuxt-auth-config-load-failed",{"title":644,"path":645,"stem":646},"Schema generator returned no code","\u002Ferrors\u002Fnuxt-auth-empty-schema","6.errors\u002Fnuxt-auth-empty-schema",{"title":648,"path":649,"stem":650},"Invalid server auth config export","\u002Ferrors\u002Fnuxt-auth-invalid-config-export","6.errors\u002Fnuxt-auth-invalid-config-export",{"title":652,"path":653,"stem":654},"Auth plugin path must be absolute","\u002Ferrors\u002Fnuxt-auth-invalid-plugin-source","6.errors\u002Fnuxt-auth-invalid-plugin-source",{"title":656,"path":657,"stem":658},"Missing auth configuration","\u002Ferrors\u002Fnuxt-auth-missing-config","6.errors\u002Fnuxt-auth-missing-config",{"title":660,"path":661,"stem":662},"NuxtHub database alias is missing","\u002Ferrors\u002Fnuxt-auth-missing-hub-db","6.errors\u002Fnuxt-auth-missing-hub-db",{"title":664,"path":665,"stem":666},"No database provider is enabled","\u002Ferrors\u002Fnuxt-auth-no-database-provider","6.errors\u002Fnuxt-auth-no-database-provider",{"title":668,"path":669,"stem":670},"Auth schema generation failed","\u002Ferrors\u002Fnuxt-auth-schema-generation-failed","6.errors\u002Fnuxt-auth-schema-generation-failed",{"title":672,"path":673,"stem":674},"Custom session storage is missing","\u002Ferrors\u002Fnuxt-auth-schema-storage-required","6.errors\u002Fnuxt-auth-schema-storage-required",{"title":676,"path":677,"stem":678},"Secondary storage in client-only mode","\u002Ferrors\u002Fnuxt-auth-storage-client-only","6.errors\u002Fnuxt-auth-storage-client-only",{"title":680,"path":681,"stem":682},"Unsupported database dialect","\u002Ferrors\u002Fnuxt-auth-unsupported-dialect","6.errors\u002Fnuxt-auth-unsupported-dialect",1796420208337,"292ab281-29cc-41c2-9aae-90672b1d4940"]