[{"data":1,"prerenderedAt":717,"buildId":718},["ShallowReactive",2],{"-guides-database-less-mode":3,"-guides-database-less-mode-surround":498,"navigation_docs":510},{"id":4,"title":5,"body":6,"description":490,"extension":491,"links":492,"meta":493,"navigation":238,"path":494,"seo":495,"stem":496,"__hash__":497},"docs\u002F3.guides\u002F4.database-less-mode.md","Database-less Mode",{"type":7,"value":8,"toc":479},"minimark",[9,13,16,27,34,39,63,68,73,76,82,86,89,93,101,105,108,113,117,120,125,136,140,143,201,205,208,436,439,443,448,459,464,475],[10,11,12],"p",{},"Use this guide when you want stateless sessions and you accept the operational tradeoffs that come with not having persistent auth records.",[10,14,15],{},"Better Auth supports running without a database using encrypted cookie sessions (JWE).",[17,18,21,22,26],"callout",{"icon":19,"to":20},"i-lucide-external-link","https:\u002F\u002Fwww.better-auth.com\u002Fdocs\u002Fconcepts\u002Fdatabase#primitives-for-database-less-auth","See the official ",[23,24,25],"strong",{},"Better Auth documentation"," for database-less setup.",[10,28,29,30,33],{},"Database-less mode uses ",[23,31,32],{},"JWE (JSON Web Encryption)"," sessions. Instead of storing sessions in a database, the session data is encrypted and stored entirely in the cookie.",[10,35,36],{},[23,37,38],{},"How it works:",[40,41,42,54,57,60],"ul",{},[43,44,45,46,50,51],"li",{},"Session data is encrypted with your singular secret or the current key in ",[47,48,49],"code",{},"BETTER_AUTH_SECRETS","\u002F",[47,52,53],{},"secrets",[43,55,56],{},"The encrypted token is stored in a cookie",[43,58,59],{},"On each request, the server decrypts the cookie to get session data",[43,61,62],{},"No database queries needed for session validation",[64,65,67],"h2",{"id":66},"limitations","Limitations",[69,70,72],"h3",{"id":71},"no-server-side-session-revocation","No Server-Side Session Revocation",[10,74,75],{},"You cannot invalidate a session before it expires. The user must wait for the cookie to expire.",[10,77,78,81],{},[23,79,80],{},"Workaround:"," Use short session lifetimes (e.g., 1 hour) and implement token refresh.",[69,83,85],{"id":84},"no-emailpassword-without-external-storage","No Email\u002FPassword Without External Storage",[10,87,88],{},"Email\u002Fpassword requires storing user credentials somewhere.",[10,90,91],{},[23,92,80],{},[40,94,95,98],{},[43,96,97],{},"Use OAuth providers only (GitHub, Google store the credentials)",[43,99,100],{},"Or use an external user database while keeping sessions database-less",[69,102,104],{"id":103},"no-multi-device-session-management","No Multi-Device Session Management",[10,106,107],{},"Cannot list or revoke sessions across devices.",[10,109,110,112],{},[23,111,80],{}," Implement device tracking in your application layer if needed.",[69,114,116],{"id":115},"oauth-considerations","OAuth Considerations",[10,118,119],{},"OAuth can work in database-less mode, but account state is stored in encrypted cookies (JWE) instead of a database. This limits server-side management and auditing.",[121,122,124],"h4",{"id":123},"when-to-avoid-db-less-oauth","When to avoid DB-less OAuth",[40,126,127,130,133],{},[43,128,129],{},"You need to list\u002Frevoke sessions across devices",[43,131,132],{},"You need durable account records (admin tools, audits)",[43,134,135],{},"You rely on server-side account linking or management",[64,137,139],{"id":138},"nuxt-configuration","Nuxt Configuration",[10,141,142],{},"Simply don't configure a database adapter:",[144,145,151],"pre",{"className":146,"code":147,"filename":148,"language":149,"meta":150,"style":150},"language-ts shiki shiki-themes one-light synthwave-84 synthwave-84","export default defineNuxtConfig({\n  modules: ['@nuxtjs\u002Fbetter-auth'],\n})\n","nuxt.config.ts","ts","",[47,152,153,174,195],{"__ignoreMap":150},[154,155,158,162,166,170],"span",{"class":156,"line":157},"line",1,[154,159,161],{"class":160},"sqe1H","export",[154,163,165],{"class":164},"sKg8T"," default",[154,167,169],{"class":168},"sfT9l"," defineNuxtConfig",[154,171,173],{"class":172},"s17Py","({\n",[154,175,177,181,185,188,192],{"class":156,"line":176},2,[154,178,180],{"class":179},"sYvLG","  modules",[154,182,184],{"class":183},"sVnqq",":",[154,186,187],{"class":172}," [",[154,189,191],{"class":190},"sPAZv","'@nuxtjs\u002Fbetter-auth'",[154,193,194],{"class":172},"],\n",[154,196,198],{"class":156,"line":197},3,[154,199,200],{"class":172},"})\n",[64,202,204],{"id":203},"auth-configuration","Auth Configuration",[10,206,207],{},"Enable JWE sessions and cookie-based OAuth state:",[144,209,212],{"className":146,"code":210,"filename":211,"language":149,"meta":150,"style":150},"import { defineServerAuth } from '@nuxtjs\u002Fbetter-auth\u002Fconfig'\n\nexport default defineServerAuth({\n  socialProviders: {\n    github: { clientId: '...', clientSecret: '...' },\n  },\n  session: {\n    cookieCache: {\n      enabled: true,\n      maxAge: 7 * 24 * 60 * 60, \u002F\u002F 7 days\n      strategy: 'jwe',\n    },\n  },\n  account: {\n    storeStateStrategy: 'cookie',\n    storeAccountCookie: true,\n  },\n})\n","server\u002Fauth.config.ts",[47,213,214,234,240,251,262,293,299,309,319,334,367,380,386,391,401,414,426,431],{"__ignoreMap":150},[154,215,216,219,222,225,228,231],{"class":156,"line":157},[154,217,218],{"class":160},"import",[154,220,221],{"class":172}," { ",[154,223,224],{"class":179},"defineServerAuth",[154,226,227],{"class":172}," } ",[154,229,230],{"class":160},"from",[154,232,233],{"class":190}," '@nuxtjs\u002Fbetter-auth\u002Fconfig'\n",[154,235,236],{"class":156,"line":176},[154,237,239],{"emptyLinePlaceholder":238},true,"\n",[154,241,242,244,246,249],{"class":156,"line":197},[154,243,161],{"class":160},[154,245,165],{"class":164},[154,247,248],{"class":168}," defineServerAuth",[154,250,173],{"class":172},[154,252,254,257,259],{"class":156,"line":253},4,[154,255,256],{"class":179},"  socialProviders",[154,258,184],{"class":183},[154,260,261],{"class":172}," {\n",[154,263,265,268,270,272,275,277,280,283,286,288,290],{"class":156,"line":264},5,[154,266,267],{"class":179},"    github",[154,269,184],{"class":183},[154,271,221],{"class":172},[154,273,274],{"class":179},"clientId",[154,276,184],{"class":183},[154,278,279],{"class":190}," '...'",[154,281,282],{"class":172},", ",[154,284,285],{"class":179},"clientSecret",[154,287,184],{"class":183},[154,289,279],{"class":190},[154,291,292],{"class":172}," },\n",[154,294,296],{"class":156,"line":295},6,[154,297,298],{"class":172},"  },\n",[154,300,302,305,307],{"class":156,"line":301},7,[154,303,304],{"class":179},"  session",[154,306,184],{"class":183},[154,308,261],{"class":172},[154,310,312,315,317],{"class":156,"line":311},8,[154,313,314],{"class":179},"    cookieCache",[154,316,184],{"class":183},[154,318,261],{"class":172},[154,320,322,325,327,331],{"class":156,"line":321},9,[154,323,324],{"class":179},"      enabled",[154,326,184],{"class":183},[154,328,330],{"class":329},"s3ZNE"," true",[154,332,333],{"class":172},",\n",[154,335,337,340,342,345,349,352,354,357,359,361,363],{"class":156,"line":336},10,[154,338,339],{"class":179},"      maxAge",[154,341,184],{"class":183},[154,343,344],{"class":329}," 7",[154,346,348],{"class":347},"sn-Jc"," *",[154,350,351],{"class":329}," 24",[154,353,348],{"class":347},[154,355,356],{"class":329}," 60",[154,358,348],{"class":347},[154,360,356],{"class":329},[154,362,282],{"class":172},[154,364,366],{"class":365},"st7cf","\u002F\u002F 7 days\n",[154,368,370,373,375,378],{"class":156,"line":369},11,[154,371,372],{"class":179},"      strategy",[154,374,184],{"class":183},[154,376,377],{"class":190}," 'jwe'",[154,379,333],{"class":172},[154,381,383],{"class":156,"line":382},12,[154,384,385],{"class":172},"    },\n",[154,387,389],{"class":156,"line":388},13,[154,390,298],{"class":172},[154,392,394,397,399],{"class":156,"line":393},14,[154,395,396],{"class":179},"  account",[154,398,184],{"class":183},[154,400,261],{"class":172},[154,402,404,407,409,412],{"class":156,"line":403},15,[154,405,406],{"class":179},"    storeStateStrategy",[154,408,184],{"class":183},[154,410,411],{"class":190}," 'cookie'",[154,413,333],{"class":172},[154,415,417,420,422,424],{"class":156,"line":416},16,[154,418,419],{"class":179},"    storeAccountCookie",[154,421,184],{"class":183},[154,423,330],{"class":329},[154,425,333],{"class":172},[154,427,429],{"class":156,"line":428},17,[154,430,298],{"class":172},[154,432,434],{"class":156,"line":433},18,[154,435,200],{"class":172},[10,437,438],{},"This stores sessions and OAuth state in encrypted cookies instead of a database.",[64,440,442],{"id":441},"when-to-use-database-less-mode","When to Use Database-less Mode",[10,444,445],{},[23,446,447],{},"Good fit:",[40,449,450,453,456],{},[43,451,452],{},"OAuth-only authentication (GitHub, Google, etc.)",[43,454,455],{},"Serverless deployments with cold start concerns",[43,457,458],{},"Simple applications without session management needs",[10,460,461],{},[23,462,463],{},"Not recommended:",[40,465,466,469,472],{},[43,467,468],{},"Applications requiring session revocation",[43,470,471],{},"Multi-device session management",[43,473,474],{},"Email\u002Fpassword authentication",[476,477,478],"style",{},"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 .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 .s3ZNE, html code.shiki .s3ZNE{--shiki-light:#986801;--shiki-default:#F97E72;--shiki-dark:#F97E72}html pre.shiki code .sn-Jc, html code.shiki .sn-Jc{--shiki-light:#0184BC;--shiki-default:#FEDE5D;--shiki-dark:#FEDE5D}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}",{"title":150,"searchDepth":176,"depth":176,"links":480},[481,487,488,489],{"id":66,"depth":176,"text":67,"children":482},[483,484,485,486],{"id":71,"depth":197,"text":72},{"id":84,"depth":197,"text":85},{"id":103,"depth":197,"text":104},{"id":115,"depth":197,"text":116},{"id":138,"depth":176,"text":139},{"id":203,"depth":176,"text":204},{"id":441,"depth":176,"text":442},"Run Better Auth without a database for edge and serverless deployments.","md",null,{},"\u002Fguides\u002Fdatabase-less-mode",{"title":5,"description":490},"3.guides\u002F4.database-less-mode","m9tKHYvLMEDCF20Ic6O3PczPR92LcHa1DGbQDu3ITN8",[499,504],{"title":500,"path":501,"stem":502,"description":503,"children":-1},"Custom Database","\u002Fguides\u002Fcustom-database","3.guides\u002F3.custom-database","Use your own database with Drizzle, Prisma, or Kysely adapters.",{"title":505,"path":506,"stem":507,"description":508,"icon":509,"children":-1},"External Auth Backend","\u002Fguides\u002Fexternal-auth-backend","3.guides\u002F5.external-auth-backend","Use nuxt-better-auth with a separate Better Auth server.","i-lucide-server",[511,549,575,612,637,658],{"title":512,"path":513,"stem":514,"children":515,"icon":518},"Getting Started","\u002Fgetting-started","1.getting-started\u002F0.index",[516,519,524,529,534,539,544],{"title":517,"path":513,"stem":514,"icon":518},"Introduction","i-lucide-sparkles",{"title":520,"path":521,"stem":522,"icon":523},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F1.installation","i-lucide-download",{"title":525,"path":526,"stem":527,"icon":528},"Configuration","\u002Fgetting-started\u002Fconfiguration","1.getting-started\u002F2.configuration","i-lucide-settings",{"title":530,"path":531,"stem":532,"icon":533},"Client Setup","\u002Fgetting-started\u002Fclient-setup","1.getting-started\u002F3.client-setup","i-lucide-monitor",{"title":535,"path":536,"stem":537,"icon":538},"Type Augmentation","\u002Fgetting-started\u002Ftype-augmentation","1.getting-started\u002F4.type-augmentation","i-lucide-type",{"title":540,"path":541,"stem":542,"icon":543},"Schema Generation (NuxtHub)","\u002Fgetting-started\u002Fschema-generation","1.getting-started\u002F5.schema-generation","i-lucide-database",{"title":545,"path":546,"stem":547,"icon":548},"How It Works","\u002Fgetting-started\u002Fhow-it-works","1.getting-started\u002F6.how-it-works","i-lucide-workflow",{"title":550,"path":551,"stem":552,"children":553,"page":574},"Core Concepts","\u002Fcore-concepts","2.core-concepts",[554,558,562,566,570],{"title":555,"path":556,"stem":557},"serverAuth()","\u002Fcore-concepts\u002Fserver-auth","2.core-concepts\u002F1.server-auth",{"title":559,"path":560,"stem":561},"Sessions","\u002Fcore-concepts\u002Fsessions","2.core-concepts\u002F2.sessions",{"title":563,"path":564,"stem":565},"Route Protection","\u002Fcore-concepts\u002Froute-protection","2.core-concepts\u002F3.route-protection",{"title":567,"path":568,"stem":569},"Auto‑Imports and Aliases","\u002Fcore-concepts\u002Fauto-imports-aliases","2.core-concepts\u002F4.auto-imports-aliases",{"title":571,"path":572,"stem":573},"Security & Caveats","\u002Fcore-concepts\u002Fsecurity-caveats","2.core-concepts\u002F5.security-caveats",false,{"title":576,"path":577,"stem":578,"children":579,"page":574},"Guides","\u002Fguides","3.guides",[580,584,589,593,594,595,596,600,604,608],{"title":581,"path":582,"stem":583},"Role‑Based Access","\u002Fguides\u002Frole-based-access","3.guides\u002F1.role-based-access",{"title":585,"path":586,"stem":587,"icon":588},"Setup diagnostics","\u002Fguides\u002Fdiagnostics","3.guides\u002F10.diagnostics","i-lucide-circle-alert",{"title":590,"path":591,"stem":592},"OAuth Providers","\u002Fguides\u002Foauth-providers","3.guides\u002F2.oauth-providers",{"title":500,"path":501,"stem":502},{"title":5,"path":494,"stem":496},{"title":505,"path":506,"stem":507,"icon":509},{"title":597,"path":598,"stem":599},"Migrating from nuxt-auth-utils","\u002Fguides\u002Fmigrate-from-nuxt-auth-utils","3.guides\u002F6.migrate-from-nuxt-auth-utils",{"title":601,"path":602,"stem":603},"Two-Factor Authentication (TOTP + Backup Codes)","\u002Fguides\u002Ftwo-factor-auth","3.guides\u002F7.two-factor-auth",{"title":605,"path":606,"stem":607},"Testing","\u002Fguides\u002Ftesting","3.guides\u002F8.testing",{"title":609,"path":610,"stem":611},"Production Deployment","\u002Fguides\u002Fproduction-deployment","3.guides\u002F9.production-deployment",{"title":613,"path":614,"stem":615,"children":616,"page":574},"Integrations","\u002Fintegrations","4.integrations",[617,621,625,629,633],{"title":618,"path":619,"stem":620},"NuxtHub","\u002Fintegrations\u002Fnuxthub","4.integrations\u002F1.nuxthub",{"title":622,"path":623,"stem":624},"DevTools","\u002Fintegrations\u002Fdevtools","4.integrations\u002F2.devtools",{"title":626,"path":627,"stem":628},"Convex","\u002Fintegrations\u002Fconvex","4.integrations\u002F3.convex",{"title":630,"path":631,"stem":632},"i18n","\u002Fintegrations\u002Fi18n","4.integrations\u002F4.i18n",{"title":634,"path":635,"stem":636},"MCP","\u002Fintegrations\u002Fmcp","4.integrations\u002F5.mcp",{"title":638,"path":639,"stem":640,"children":641,"page":574},"API Reference","\u002Fapi","5.api",[642,646,650,654],{"title":643,"path":644,"stem":645},"Composables","\u002Fapi\u002Fcomposables","5.api\u002F1.composables",{"title":647,"path":648,"stem":649},"Server Utilities","\u002Fapi\u002Fserver-utils","5.api\u002F2.server-utils",{"title":651,"path":652,"stem":653},"Components","\u002Fapi\u002Fcomponents","5.api\u002F3.components",{"title":655,"path":656,"stem":657},"Types","\u002Fapi\u002Ftypes","5.api\u002F4.types",{"title":659,"path":660,"stem":661,"children":662,"icon":588},"Errors","\u002Ferrors","6.errors\u002F0.index",[663,665,669,673,677,681,685,689,693,697,701,705,709,713],{"title":664,"path":660,"stem":661},"Overview",{"title":666,"path":667,"stem":668},"Better Auth CLI is not installed","\u002Ferrors\u002Fnuxt-auth-cli-missing","6.errors\u002Fnuxt-auth-cli-missing",{"title":670,"path":671,"stem":672},"Better Auth CLI version does not match better-auth","\u002Ferrors\u002Fnuxt-auth-cli-version-mismatch","6.errors\u002Fnuxt-auth-cli-version-mismatch",{"title":674,"path":675,"stem":676},"Auth configuration failed to load","\u002Ferrors\u002Fnuxt-auth-config-load-failed","6.errors\u002Fnuxt-auth-config-load-failed",{"title":678,"path":679,"stem":680},"Schema generator returned no code","\u002Ferrors\u002Fnuxt-auth-empty-schema","6.errors\u002Fnuxt-auth-empty-schema",{"title":682,"path":683,"stem":684},"Invalid server auth config export","\u002Ferrors\u002Fnuxt-auth-invalid-config-export","6.errors\u002Fnuxt-auth-invalid-config-export",{"title":686,"path":687,"stem":688},"Auth plugin path must be absolute","\u002Ferrors\u002Fnuxt-auth-invalid-plugin-source","6.errors\u002Fnuxt-auth-invalid-plugin-source",{"title":690,"path":691,"stem":692},"Missing auth configuration","\u002Ferrors\u002Fnuxt-auth-missing-config","6.errors\u002Fnuxt-auth-missing-config",{"title":694,"path":695,"stem":696},"NuxtHub database alias is missing","\u002Ferrors\u002Fnuxt-auth-missing-hub-db","6.errors\u002Fnuxt-auth-missing-hub-db",{"title":698,"path":699,"stem":700},"No database provider is enabled","\u002Ferrors\u002Fnuxt-auth-no-database-provider","6.errors\u002Fnuxt-auth-no-database-provider",{"title":702,"path":703,"stem":704},"Auth schema generation failed","\u002Ferrors\u002Fnuxt-auth-schema-generation-failed","6.errors\u002Fnuxt-auth-schema-generation-failed",{"title":706,"path":707,"stem":708},"Custom session storage is missing","\u002Ferrors\u002Fnuxt-auth-schema-storage-required","6.errors\u002Fnuxt-auth-schema-storage-required",{"title":710,"path":711,"stem":712},"Secondary storage in client-only mode","\u002Ferrors\u002Fnuxt-auth-storage-client-only","6.errors\u002Fnuxt-auth-storage-client-only",{"title":714,"path":715,"stem":716},"Unsupported database dialect","\u002Ferrors\u002Fnuxt-auth-unsupported-dialect","6.errors\u002Fnuxt-auth-unsupported-dialect",1795996230517,"6c3c8832-e88a-4d4f-9e6d-7fef286a1917"]