[{"data":1,"prerenderedAt":412},["ShallowReactive",2],{"navigation_docs":3,"-getting-started-how-it-works":152,"-getting-started-how-it-works-surround":407},[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":38,"body":154,"description":400,"extension":401,"links":402,"meta":403,"navigation":404,"path":39,"seo":405,"stem":40,"__hash__":406},"docs\u002F1.getting-started\u002F6.how-it-works.md",{"type":155,"value":156,"toc":387},"minimark",[157,161,166,212,216,318,322,360,364],[158,159,160],"p",{},"Use this page after installation. It explains how the module connects Nuxt runtime behavior to Better Auth rather than walking through setup again.",[162,163,165],"h2",{"id":164},"architecture","Architecture",[167,168,169,174,187,191,201,205],"steps",{},[170,171,173],"h3",{"id":172},"initialization","Initialization",[158,175,176,177,181,182,186],{},"During build, the module reads ",[178,179,180],"code",{},"server\u002Fauth.config.ts"," and generates the auth handler. If using ",[183,184],"brand-badge",{"name":185},"nuxthub",", it also generates the database schema automatically.",[170,188,190],{"id":189},"server-runtime","Server Runtime",[158,192,193,194,197,198,200],{},"The module injects a catch-all API handler at ",[178,195,196],{},"\u002Fapi\u002Fauth\u002F**",". This handler processes all authentication requests (login, logout, session fetching) using the configuration provided in ",[178,199,180],{},".",[170,202,204],{"id":203},"client-runtime","Client Runtime",[158,206,207,208,211],{},"On the client side, ",[178,209,210],{},"useUserSession"," initializes the Better Auth client. It establishes a reactive connection to the session state, ensuring that your UI updates immediately when a user logs in or out.",[162,213,215],{"id":214},"key-responsibilities","Key Responsibilities",[217,218,219,235],"table",{},[220,221,222],"thead",{},[223,224,225,229,232],"tr",{},[226,227,228],"th",{},"Feature",[226,230,231],{},"What it provides",[226,233,234],{},"Side",[236,237,238,253,266,283,300],"tbody",{},[223,239,240,244,250],{},[241,242,243],"td",{},"Server handler",[241,245,246,247],{},"Mounts Better Auth at ",[178,248,249],{},"\u002Fapi\u002Fauth\u002F*",[241,251,252],{},"Server",[223,254,255,257,263],{},[241,256,137],{},[241,258,259,262],{},[178,260,261],{},"useUserSession()"," for reactive state",[241,264,265],{},"Client",[223,267,268,271,281],{},[241,269,270],{},"Server utils",[241,272,273,276,277,280],{},[178,274,275],{},"serverAuth(event?)",", ",[178,278,279],{},"getUserSession(event)",", etc.",[241,282,252],{},[223,284,285,288,297],{},[241,286,287],{},"Route protection",[241,289,290,293,294],{},[178,291,292],{},"routeRules.auth"," and ",[178,295,296],{},"definePageMeta({ auth })",[241,298,299],{},"Both",[223,301,302,305,315],{},[241,303,304],{},"Type augmentation",[241,306,307,308,293,311,314],{},"Inferred ",[178,309,310],{},"AuthUser",[178,312,313],{},"AuthSession"," types",[241,316,317],{},"Build",[162,319,321],{"id":320},"request-flow","Request Flow",[323,324,325,329,340,343,349,352,355],"ol",{},[326,327,328],"li",{},"User visits a protected page",[326,330,331,332,335,336,339],{},"Route middleware checks ",[178,333,334],{},"auth"," rule in ",[178,337,338],{},"routeRules"," or page meta",[326,341,342],{},"If not authenticated, redirects to login page",[326,344,345,346],{},"User submits credentials to ",[178,347,348],{},"\u002Fapi\u002Fauth\u002Fsign-in\u002Femail",[326,350,351],{},"Better Auth validates credentials and creates session",[326,353,354],{},"Session cookie is set, user redirected to original page",[326,356,357,359],{},[178,358,261],{}," reads session from cookie, updates reactive state",[162,361,363],{"id":362},"what-this-means-in-practice","What this means in practice",[365,366,367,373,379,382],"ul",{},[326,368,369,370,372],{},"client pages use ",[178,371,261],{}," and related composables",[326,374,375,376],{},"protected API routes should still call ",[178,377,378],{},"requireUserSession(event)",[326,380,381],{},"route rules improve navigation UX, but server-side checks remain the real security boundary",[326,383,384,386],{},[183,385],{"name":185}," integration and schema generation are build-time concerns, not request-time concerns",{"title":388,"searchDepth":389,"depth":389,"links":390},"",2,[391,397,398,399],{"id":164,"depth":389,"text":165,"children":392},[393,395,396],{"id":172,"depth":394,"text":173},3,{"id":189,"depth":394,"text":190},{"id":203,"depth":394,"text":204},{"id":214,"depth":389,"text":215},{"id":320,"depth":389,"text":321},{"id":362,"depth":389,"text":363},"Understand the architecture after completing setup.","md",null,{},{"icon":41},{"title":38,"description":400},"4pDwAR4dANKn7Dpbpxda5EKCVCZiUCOOeyLuH85liGk",[408,410],{"title":33,"path":34,"stem":35,"description":409,"icon":36,"children":-1},"Auto-generate Drizzle ORM schemas for Better Auth tables when using NuxtHub.",{"title":48,"path":49,"stem":50,"description":411,"children":-1},"When to reach for the full Better Auth server instance.",1788606330303]