[{"data":1,"prerenderedAt":1129},["ShallowReactive",2],{"navigation_docs":3,"-logging-better-auth-middleware":392,"-logging-better-auth-middleware-surround":1124},[4,35,159,201,289,376],{"title":5,"path":6,"stem":7,"children":8,"page":34},"Getting Started","\u002Fgetting-started","1.getting-started",[9,14,19,24,29],{"title":10,"path":11,"stem":12,"icon":13},"Introduction","\u002Fgetting-started\u002Fintroduction","1.getting-started\u002F1.introduction","i-lucide-info",{"title":15,"path":16,"stem":17,"icon":18},"Installation","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":20,"path":21,"stem":22,"icon":23},"Quick Start","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F3.quick-start","i-lucide-zap",{"title":25,"path":26,"stem":27,"icon":28},"Agent Skills","\u002Fgetting-started\u002Fagent-skills","1.getting-started\u002F4.agent-skills","i-lucide-sparkles",{"title":30,"path":31,"stem":32,"icon":33},"vs Other Loggers","\u002Fgetting-started\u002Fvs-other-loggers","1.getting-started\u002F5.vs-other-loggers","i-lucide-scale",false,{"title":36,"path":37,"stem":38,"children":39,"page":34},"Logging","\u002Flogging","2.logging",[40,45,50,55,60,65,70,99,127],{"title":41,"path":42,"stem":43,"icon":44},"Overview","\u002Flogging\u002Foverview","2.logging\u002F0.overview","i-lucide-list",{"title":46,"path":47,"stem":48,"icon":49},"Simple Logging","\u002Flogging\u002Fsimple-logging","2.logging\u002F1.simple-logging","i-lucide-terminal",{"title":51,"path":52,"stem":53,"icon":54},"Wide Events","\u002Flogging\u002Fwide-events","2.logging\u002F2.wide-events","i-lucide-layers",{"title":56,"path":57,"stem":58,"icon":59},"Structured Errors","\u002Flogging\u002Fstructured-errors","2.logging\u002F3.structured-errors","i-lucide-shield-alert",{"title":61,"path":62,"stem":63,"icon":64},"Catalogs","\u002Flogging\u002Fcatalogs","2.logging\u002F4.catalogs","i-lucide-book-open",{"title":66,"path":67,"stem":68,"icon":69},"Client Logging","\u002Flogging\u002Fclient-logging","2.logging\u002F5.client-logging","i-lucide-monitor",{"title":71,"icon":72,"path":73,"stem":74,"children":75,"page":34},"AI SDK","i-simple-icons-vercel","\u002Flogging\u002Fai-sdk","2.logging\u002F6.ai-sdk",[76,79,84,89,94],{"title":41,"path":77,"stem":78,"icon":44},"\u002Flogging\u002Fai-sdk\u002Foverview","2.logging\u002F6.ai-sdk\u002F01.overview",{"title":80,"path":81,"stem":82,"icon":83},"Usage","\u002Flogging\u002Fai-sdk\u002Fusage","2.logging\u002F6.ai-sdk\u002F02.usage","i-lucide-code",{"title":85,"path":86,"stem":87,"icon":88},"Options","\u002Flogging\u002Fai-sdk\u002Foptions","2.logging\u002F6.ai-sdk\u002F03.options","i-lucide-sliders",{"title":90,"path":91,"stem":92,"icon":93},"Metadata","\u002Flogging\u002Fai-sdk\u002Fmetadata","2.logging\u002F6.ai-sdk\u002F04.metadata","i-lucide-database",{"title":95,"path":96,"stem":97,"icon":98},"Telemetry","\u002Flogging\u002Fai-sdk\u002Ftelemetry","2.logging\u002F6.ai-sdk\u002F05.telemetry","i-lucide-activity",{"title":100,"icon":101,"path":102,"stem":103,"children":104,"page":34},"Better Auth","i-simple-icons-betterauth","\u002Flogging\u002Fbetter-auth","2.logging\u002F7.better-auth",[105,108,113,118,122],{"title":41,"path":106,"stem":107,"icon":44},"\u002Flogging\u002Fbetter-auth\u002Foverview","2.logging\u002F7.better-auth\u002F01.overview",{"title":109,"path":110,"stem":111,"icon":112},"Identify User","\u002Flogging\u002Fbetter-auth\u002Fidentify-user","2.logging\u002F7.better-auth\u002F02.identify-user","i-lucide-user-check",{"title":114,"path":115,"stem":116,"icon":117},"Middleware","\u002Flogging\u002Fbetter-auth\u002Fmiddleware","2.logging\u002F7.better-auth\u002F03.middleware","i-lucide-shield",{"title":119,"path":120,"stem":121,"icon":69},"Client Sync","\u002Flogging\u002Fbetter-auth\u002Fclient-sync","2.logging\u002F7.better-auth\u002F04.client-sync",{"title":123,"path":124,"stem":125,"icon":126},"Performance","\u002Flogging\u002Fbetter-auth\u002Fperformance","2.logging\u002F7.better-auth\u002F05.performance","i-lucide-gauge",{"title":128,"icon":129,"path":130,"stem":131,"children":132,"page":34},"Audit Logs","i-lucide-shield-check","\u002Flogging\u002Faudit","2.logging\u002F8.audit",[133,136,141,146,151,155],{"title":41,"path":134,"stem":135,"icon":44},"\u002Flogging\u002Faudit\u002Foverview","2.logging\u002F8.audit\u002F01.overview",{"title":137,"path":138,"stem":139,"icon":140},"Schema","\u002Flogging\u002Faudit\u002Fschema","2.logging\u002F8.audit\u002F02.schema","i-lucide-file-text",{"title":142,"path":143,"stem":144,"icon":145},"Recording","\u002Flogging\u002Faudit\u002Frecording","2.logging\u002F8.audit\u002F03.recording","i-lucide-pen-line",{"title":147,"path":148,"stem":149,"icon":150},"Drains","\u002Flogging\u002Faudit\u002Fpipeline","2.logging\u002F8.audit\u002F04.pipeline","i-lucide-link",{"title":152,"path":153,"stem":154,"icon":129},"Compliance","\u002Flogging\u002Faudit\u002Fcompliance","2.logging\u002F8.audit\u002F05.compliance",{"title":156,"path":157,"stem":158,"icon":64},"Recipes","\u002Flogging\u002Faudit\u002Frecipes","2.logging\u002F8.audit\u002F06.recipes",{"title":160,"path":161,"stem":162,"children":163,"page":34},"Core Concepts","\u002Fcore-concepts","3.core-concepts",[164,169,174,179,184,188,191,196],{"title":165,"path":166,"stem":167,"icon":168},"Lifecycle","\u002Fcore-concepts\u002Flifecycle","3.core-concepts\u002F0.lifecycle","i-lucide-arrow-right-left",{"title":170,"path":171,"stem":172,"icon":173},"Configuration","\u002Fcore-concepts\u002Fconfiguration","3.core-concepts\u002F1.configuration","i-lucide-settings",{"title":175,"path":176,"stem":177,"icon":178},"Sampling","\u002Fcore-concepts\u002Fsampling","3.core-concepts\u002F2.sampling","i-lucide-filter",{"title":180,"path":181,"stem":182,"icon":183},"Typed Fields","\u002Fcore-concepts\u002Ftyped-fields","3.core-concepts\u002F3.typed-fields","i-simple-icons-typescript",{"title":185,"path":186,"stem":187,"icon":129},"Best Practices","\u002Fcore-concepts\u002Fbest-practices","3.core-concepts\u002F4.best-practices",{"title":123,"path":189,"stem":190,"icon":126},"\u002Fcore-concepts\u002Fperformance","3.core-concepts\u002F5.performance",{"title":192,"path":193,"stem":194,"icon":195},"Vite Plugin","\u002Fcore-concepts\u002Fvite-plugin","3.core-concepts\u002F6.vite-plugin","i-custom-vite",{"title":197,"path":198,"stem":199,"icon":200},"Auto-Redaction","\u002Fcore-concepts\u002Fredaction","3.core-concepts\u002F7.redaction","i-lucide-eye-off",{"title":202,"path":203,"stem":204,"children":205,"page":34},"Frameworks","\u002Fframeworks","4.frameworks",[206,210,215,220,225,230,235,240,245,250,255,260,265,270,274,279,284],{"title":41,"path":207,"stem":208,"icon":209},"\u002Fframeworks\u002Foverview","4.frameworks\u002F00.overview","i-lucide-layout-grid",{"title":211,"path":212,"stem":213,"icon":214},"Nuxt","\u002Fframeworks\u002Fnuxt","4.frameworks\u002F01.nuxt","i-simple-icons-nuxtdotjs",{"title":216,"path":217,"stem":218,"icon":219},"Next.js","\u002Fframeworks\u002Fnextjs","4.frameworks\u002F02.nextjs","i-simple-icons-nextdotjs",{"title":221,"path":222,"stem":223,"icon":224},"SvelteKit","\u002Fframeworks\u002Fsveltekit","4.frameworks\u002F03.sveltekit","i-simple-icons-svelte",{"title":226,"path":227,"stem":228,"icon":229},"Nitro","\u002Fframeworks\u002Fnitro","4.frameworks\u002F04.nitro","i-custom-nitro",{"title":231,"path":232,"stem":233,"icon":234},"TanStack Start","\u002Fframeworks\u002Ftanstack-start","4.frameworks\u002F05.tanstack-start","i-custom-tanstack",{"title":236,"path":237,"stem":238,"icon":239},"NestJS","\u002Fframeworks\u002Fnestjs","4.frameworks\u002F06.nestjs","i-simple-icons-nestjs",{"title":241,"path":242,"stem":243,"icon":244},"Express","\u002Fframeworks\u002Fexpress","4.frameworks\u002F07.express","i-simple-icons-express",{"title":246,"path":247,"stem":248,"icon":249},"Hono","\u002Fframeworks\u002Fhono","4.frameworks\u002F08.hono","i-simple-icons-hono",{"title":251,"path":252,"stem":253,"icon":254},"Fastify","\u002Fframeworks\u002Ffastify","4.frameworks\u002F09.fastify","i-simple-icons-fastify",{"title":256,"path":257,"stem":258,"icon":259},"Elysia","\u002Fframeworks\u002Felysia","4.frameworks\u002F10.elysia","i-custom-elysia",{"title":261,"path":262,"stem":263,"icon":264},"React Router","\u002Fframeworks\u002Freact-router","4.frameworks\u002F11.react-router","i-custom-reactrouter",{"title":266,"path":267,"stem":268,"icon":269},"Cloudflare Workers","\u002Fframeworks\u002Fcloudflare-workers","4.frameworks\u002F12.cloudflare-workers","i-simple-icons-cloudflare",{"title":271,"path":272,"stem":273,"icon":183},"Standalone","\u002Fframeworks\u002Fstandalone","4.frameworks\u002F13.standalone",{"title":275,"path":276,"stem":277,"icon":278},"Astro","\u002Fframeworks\u002Fastro","4.frameworks\u002F14.astro","i-simple-icons-astro",{"title":280,"path":281,"stem":282,"icon":283},"AWS Lambda","\u002Fframeworks\u002Faws-lambda","4.frameworks\u002F16.aws-lambda","i-custom-lambda",{"title":285,"path":286,"stem":287,"icon":288},"Custom Integration","\u002Fframeworks\u002Fcustom-integration","4.frameworks\u002F17.custom-integration","i-lucide-puzzle",{"title":290,"path":291,"stem":292,"children":293,"page":34},"Adapters","\u002Fadapters","6.adapters",[294,297,337,352],{"title":41,"path":295,"stem":296,"icon":44},"\u002Fadapters\u002Foverview","6.adapters\u002F01.overview",{"title":298,"path":299,"stem":300,"children":301,"page":34},"Cloud destinations","\u002Fadapters\u002Fcloud","6.adapters\u002F02.cloud",[302,307,312,317,322,327,332],{"title":303,"path":304,"stem":305,"icon":306},"Axiom","\u002Fadapters\u002Fcloud\u002Faxiom","6.adapters\u002F02.cloud\u002F01.axiom","i-custom-axiom",{"title":308,"path":309,"stem":310,"icon":311},"OTLP","\u002Fadapters\u002Fcloud\u002Fotlp","6.adapters\u002F02.cloud\u002F02.otlp","i-simple-icons-opentelemetry",{"title":313,"path":314,"stem":315,"icon":316},"PostHog","\u002Fadapters\u002Fcloud\u002Fposthog","6.adapters\u002F02.cloud\u002F03.posthog","i-simple-icons-posthog",{"title":318,"path":319,"stem":320,"icon":321},"Sentry","\u002Fadapters\u002Fcloud\u002Fsentry","6.adapters\u002F02.cloud\u002F04.sentry","i-simple-icons-sentry",{"title":323,"path":324,"stem":325,"icon":326},"Better Stack","\u002Fadapters\u002Fcloud\u002Fbetter-stack","6.adapters\u002F02.cloud\u002F05.better-stack","i-simple-icons-betterstack",{"title":328,"path":329,"stem":330,"icon":331},"Datadog","\u002Fadapters\u002Fcloud\u002Fdatadog","6.adapters\u002F02.cloud\u002F06.datadog","i-simple-icons-datadog",{"title":333,"path":334,"stem":335,"icon":336},"HyperDX","\u002Fadapters\u002Fcloud\u002Fhyperdx","6.adapters\u002F02.cloud\u002F07.hyperdx","i-custom-hyperdx",{"title":338,"path":339,"stem":340,"children":341,"page":34},"Self-hosted","\u002Fadapters\u002Fself-hosted","6.adapters\u002F03.self-hosted",[342,347],{"title":343,"path":344,"stem":345,"icon":346},"File System","\u002Fadapters\u002Fself-hosted\u002Ffs","6.adapters\u002F03.self-hosted\u002F01.fs","i-lucide-hard-drive",{"title":348,"path":349,"stem":350,"icon":351},"NuxtHub","\u002Fadapters\u002Fself-hosted\u002Fnuxthub","6.adapters\u002F03.self-hosted\u002F02.nuxthub","i-simple-icons-nuxt",{"title":353,"path":354,"stem":355,"children":356,"page":34},"Building blocks","\u002Fadapters\u002Fbuilding-blocks","6.adapters\u002F04.building-blocks",[357,362,367,371],{"title":358,"path":359,"stem":360,"icon":361},"Pipeline","\u002Fadapters\u002Fbuilding-blocks\u002Fpipeline","6.adapters\u002F04.building-blocks\u002F01.pipeline","i-lucide-workflow",{"title":363,"path":364,"stem":365,"icon":366},"HTTP","\u002Fadapters\u002Fbuilding-blocks\u002Fhttp","6.adapters\u002F04.building-blocks\u002F02.http","i-lucide-globe",{"title":368,"path":369,"stem":370,"icon":83},"Custom Adapters","\u002Fadapters\u002Fbuilding-blocks\u002Fcustom","6.adapters\u002F04.building-blocks\u002F03.custom",{"title":372,"path":373,"stem":374,"icon":375},"Toolkit","\u002Fadapters\u002Fbuilding-blocks\u002Ftoolkit","6.adapters\u002F04.building-blocks\u002F04.toolkit","i-lucide-blocks",{"title":377,"path":378,"stem":379,"children":380,"page":34},"Enrichers","\u002Fenrichers","7.enrichers",[381,384,388],{"title":41,"path":382,"stem":383,"icon":28},"\u002Fenrichers\u002Foverview","7.enrichers\u002F1.overview",{"title":385,"path":386,"stem":387,"icon":288},"Built-in","\u002Fenrichers\u002Fbuilt-in","7.enrichers\u002F2.built-in",{"title":389,"path":390,"stem":391,"icon":83},"Custom","\u002Fenrichers\u002Fcustom","7.enrichers\u002F3.custom",{"id":393,"title":394,"body":395,"description":1113,"extension":1114,"links":1115,"meta":1120,"navigation":1121,"path":115,"seo":1122,"stem":116,"__hash__":1123},"docs\u002F2.logging\u002F7.better-auth\u002F03.middleware.md","createAuthMiddleware",{"type":396,"value":397,"toc":1107},"minimark",[398,409,564,578,582,593,696,700,703,788,791,846,868,872,878,1053,1065,1086,1090,1103],[399,400,401,404,405,408],"p",{},[402,403,394],"code",{}," wraps ",[402,406,407],{},"identifyUser"," with the things you need on every request: route filtering, session resolution timing, lifecycle hooks, and silent error handling. Call it once at startup, then use the returned function in your framework's middleware\u002Fhook system.",[410,411,417],"pre",{"className":412,"code":413,"filename":414,"language":415,"meta":416,"style":416},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { createAuthMiddleware } from 'evlog\u002Fbetter-auth'\n\nconst identify = createAuthMiddleware(auth, {\n  exclude: ['\u002Fapi\u002Fauth\u002F**', '\u002Fapi\u002Fpublic\u002F**'],\n  include: ['\u002Fapi\u002F**'],\n  maskEmail: true,\n})\n","server\u002Fmiddleware\u002Fauth-identify.ts","typescript","",[402,418,419,452,459,484,520,541,555],{"__ignoreMap":416},[420,421,424,428,432,436,439,442,445,449],"span",{"class":422,"line":423},"line",1,[420,425,427],{"class":426},"s7zQu","import",[420,429,431],{"class":430},"sMK4o"," {",[420,433,435],{"class":434},"sTEyZ"," createAuthMiddleware",[420,437,438],{"class":430}," }",[420,440,441],{"class":426}," from",[420,443,444],{"class":430}," '",[420,446,448],{"class":447},"sfazB","evlog\u002Fbetter-auth",[420,450,451],{"class":430},"'\n",[420,453,455],{"class":422,"line":454},2,[420,456,458],{"emptyLinePlaceholder":457},true,"\n",[420,460,462,466,469,472,475,478,481],{"class":422,"line":461},3,[420,463,465],{"class":464},"spNyl","const",[420,467,468],{"class":434}," identify ",[420,470,471],{"class":430},"=",[420,473,435],{"class":474},"s2Zo4",[420,476,477],{"class":434},"(auth",[420,479,480],{"class":430},",",[420,482,483],{"class":430}," {\n",[420,485,487,491,494,497,500,503,505,507,509,512,514,517],{"class":422,"line":486},4,[420,488,490],{"class":489},"swJcz","  exclude",[420,492,493],{"class":430},":",[420,495,496],{"class":434}," [",[420,498,499],{"class":430},"'",[420,501,502],{"class":447},"\u002Fapi\u002Fauth\u002F**",[420,504,499],{"class":430},[420,506,480],{"class":430},[420,508,444],{"class":430},[420,510,511],{"class":447},"\u002Fapi\u002Fpublic\u002F**",[420,513,499],{"class":430},[420,515,516],{"class":434},"]",[420,518,519],{"class":430},",\n",[420,521,523,526,528,530,532,535,537,539],{"class":422,"line":522},5,[420,524,525],{"class":489},"  include",[420,527,493],{"class":430},[420,529,496],{"class":434},[420,531,499],{"class":430},[420,533,534],{"class":447},"\u002Fapi\u002F**",[420,536,499],{"class":430},[420,538,516],{"class":434},[420,540,519],{"class":430},[420,542,544,547,549,553],{"class":422,"line":543},6,[420,545,546],{"class":489},"  maskEmail",[420,548,493],{"class":430},[420,550,552],{"class":551},"sfNiH"," true",[420,554,519],{"class":430},[420,556,558,561],{"class":422,"line":557},7,[420,559,560],{"class":430},"}",[420,562,563],{"class":434},")\n",[399,565,566,567,570,571,573,574,577],{},"The function signature is ",[402,568,569],{},"(log, headers, path?) => Promise\u003Cboolean>",". It resolves the session, calls ",[402,572,407],{},", captures timing into ",[402,575,576],{},"auth.resolvedIn",", fires lifecycle hooks, and silently catches errors so session resolution never breaks a request.",[579,580,85],"h2",{"id":581},"options",[399,583,584,585,592],{},"Inherits all ",[586,587,589,591],"a",{"href":588},"\u002Flogging\u002Fbetter-auth\u002Fidentify-user#options",[402,590,407],{}," options",", plus:",[594,595,596,615],"table",{},[597,598,599],"thead",{},[600,601,602,606,609,612],"tr",{},[603,604,605],"th",{},"Option",[603,607,608],{},"Type",[603,610,611],{},"Default",[603,613,614],{},"Description",[616,617,618,639,658,677],"tbody",{},[600,619,620,626,631,636],{},[621,622,623],"td",{},[402,624,625],{},"exclude",[621,627,628],{},[402,629,630],{},"string[]",[621,632,633],{},[402,634,635],{},"['\u002Fapi\u002Fauth\u002F**']",[621,637,638],{},"Route patterns to skip (glob).",[600,640,641,646,650,655],{},[621,642,643],{},[402,644,645],{},"include",[621,647,648],{},[402,649,630],{},[621,651,652],{},[402,653,654],{},"undefined",[621,656,657],{},"If set, only matching routes are resolved.",[600,659,660,665,670,674],{},[621,661,662],{},[402,663,664],{},"onIdentify",[621,666,667],{},[402,668,669],{},"(log, session) => void",[621,671,672],{},[402,673,654],{},[621,675,676],{},"Called after successful identification.",[600,678,679,684,689,693],{},[621,680,681],{},[402,682,683],{},"onAnonymous",[621,685,686],{},[402,687,688],{},"(log) => void",[621,690,691],{},[402,692,654],{},[621,694,695],{},"Called when no session is found.",[579,697,699],{"id":698},"route-filtering","Route Filtering",[399,701,702],{},"Skip Better Auth's own routes and any public endpoints to avoid wasted database queries:",[410,704,706],{"className":412,"code":705,"language":415,"meta":416,"style":416},"const identify = createAuthMiddleware(auth, {\n  exclude: [\n    '\u002Fapi\u002Fauth\u002F**',     \u002F\u002F Better Auth itself\n    '\u002Fapi\u002Fpublic\u002F**',   \u002F\u002F Public endpoints\n    '\u002Fapi\u002Fhealth',      \u002F\u002F Health checks\n  ],\n})\n",[402,707,708,724,733,748,761,775,782],{"__ignoreMap":416},[420,709,710,712,714,716,718,720,722],{"class":422,"line":423},[420,711,465],{"class":464},[420,713,468],{"class":434},[420,715,471],{"class":430},[420,717,435],{"class":474},[420,719,477],{"class":434},[420,721,480],{"class":430},[420,723,483],{"class":430},[420,725,726,728,730],{"class":422,"line":454},[420,727,490],{"class":489},[420,729,493],{"class":430},[420,731,732],{"class":434}," [\n",[420,734,735,738,740,742,744],{"class":422,"line":461},[420,736,737],{"class":430},"    '",[420,739,502],{"class":447},[420,741,499],{"class":430},[420,743,480],{"class":430},[420,745,747],{"class":746},"sHwdD","     \u002F\u002F Better Auth itself\n",[420,749,750,752,754,756,758],{"class":422,"line":486},[420,751,737],{"class":430},[420,753,511],{"class":447},[420,755,499],{"class":430},[420,757,480],{"class":430},[420,759,760],{"class":746},"   \u002F\u002F Public endpoints\n",[420,762,763,765,768,770,772],{"class":422,"line":522},[420,764,737],{"class":430},[420,766,767],{"class":447},"\u002Fapi\u002Fhealth",[420,769,499],{"class":430},[420,771,480],{"class":430},[420,773,774],{"class":746},"      \u002F\u002F Health checks\n",[420,776,777,780],{"class":422,"line":543},[420,778,779],{"class":434},"  ]",[420,781,519],{"class":430},[420,783,784,786],{"class":422,"line":557},[420,785,560],{"class":430},[420,787,563],{"class":434},[399,789,790],{},"For high-traffic apps, flip the model — only resolve sessions on routes that need them:",[410,792,794],{"className":412,"code":793,"language":415,"meta":416,"style":416},"const identify = createAuthMiddleware(auth, {\n  include: ['\u002Fapi\u002Fdashboard\u002F**', '\u002Fapi\u002Faccount\u002F**'],\n})\n",[402,795,796,812,840],{"__ignoreMap":416},[420,797,798,800,802,804,806,808,810],{"class":422,"line":423},[420,799,465],{"class":464},[420,801,468],{"class":434},[420,803,471],{"class":430},[420,805,435],{"class":474},[420,807,477],{"class":434},[420,809,480],{"class":430},[420,811,483],{"class":430},[420,813,814,816,818,820,822,825,827,829,831,834,836,838],{"class":422,"line":454},[420,815,525],{"class":489},[420,817,493],{"class":430},[420,819,496],{"class":434},[420,821,499],{"class":430},[420,823,824],{"class":447},"\u002Fapi\u002Fdashboard\u002F**",[420,826,499],{"class":430},[420,828,480],{"class":430},[420,830,444],{"class":430},[420,832,833],{"class":447},"\u002Fapi\u002Faccount\u002F**",[420,835,499],{"class":430},[420,837,516],{"class":434},[420,839,519],{"class":430},[420,841,842,844],{"class":422,"line":461},[420,843,560],{"class":430},[420,845,563],{"class":434},[399,847,848,850,851,853,854,857,858,861,862,864,865,867],{},[402,849,645],{}," and ",[402,852,625],{}," use glob patterns (",[402,855,856],{},"*",", ",[402,859,860],{},"**","). Provide both if you need granular control — ",[402,863,625],{}," wins over ",[402,866,645],{},".",[579,869,871],{"id":870},"lifecycle-hooks","Lifecycle Hooks",[399,873,874,875,877],{},"Use ",[402,876,664],{}," to react to user identification — for example, force-keep logs for premium users via tail sampling:",[410,879,881],{"className":412,"code":880,"filename":414,"language":415,"meta":416,"style":416},"const identify = createAuthMiddleware(auth, {\n  onIdentify: (log, session) => {\n    if (session.user.plan === 'enterprise') {\n      log.set({ _forceKeep: true })\n    }\n  },\n  onAnonymous: (log) => {\n    log.set({ anonymous: true })\n  },\n})\n",[402,882,883,899,926,962,989,994,999,1016,1041,1046],{"__ignoreMap":416},[420,884,885,887,889,891,893,895,897],{"class":422,"line":423},[420,886,465],{"class":464},[420,888,468],{"class":434},[420,890,471],{"class":430},[420,892,435],{"class":474},[420,894,477],{"class":434},[420,896,480],{"class":430},[420,898,483],{"class":430},[420,900,901,904,906,909,913,915,918,921,924],{"class":422,"line":454},[420,902,903],{"class":474},"  onIdentify",[420,905,493],{"class":430},[420,907,908],{"class":430}," (",[420,910,912],{"class":911},"sHdIc","log",[420,914,480],{"class":430},[420,916,917],{"class":911}," session",[420,919,920],{"class":430},")",[420,922,923],{"class":464}," =>",[420,925,483],{"class":430},[420,927,928,931,933,936,938,941,943,946,949,951,954,956,959],{"class":422,"line":461},[420,929,930],{"class":426},"    if",[420,932,908],{"class":489},[420,934,935],{"class":434},"session",[420,937,867],{"class":430},[420,939,940],{"class":434},"user",[420,942,867],{"class":430},[420,944,945],{"class":434},"plan",[420,947,948],{"class":430}," ===",[420,950,444],{"class":430},[420,952,953],{"class":447},"enterprise",[420,955,499],{"class":430},[420,957,958],{"class":489},") ",[420,960,961],{"class":430},"{\n",[420,963,964,967,969,972,975,978,981,983,985,987],{"class":422,"line":486},[420,965,966],{"class":434},"      log",[420,968,867],{"class":430},[420,970,971],{"class":474},"set",[420,973,974],{"class":489},"(",[420,976,977],{"class":430},"{",[420,979,980],{"class":489}," _forceKeep",[420,982,493],{"class":430},[420,984,552],{"class":551},[420,986,438],{"class":430},[420,988,563],{"class":489},[420,990,991],{"class":422,"line":522},[420,992,993],{"class":430},"    }\n",[420,995,996],{"class":422,"line":543},[420,997,998],{"class":430},"  },\n",[420,1000,1001,1004,1006,1008,1010,1012,1014],{"class":422,"line":557},[420,1002,1003],{"class":474},"  onAnonymous",[420,1005,493],{"class":430},[420,1007,908],{"class":430},[420,1009,912],{"class":911},[420,1011,920],{"class":430},[420,1013,923],{"class":464},[420,1015,483],{"class":430},[420,1017,1019,1022,1024,1026,1028,1030,1033,1035,1037,1039],{"class":422,"line":1018},8,[420,1020,1021],{"class":434},"    log",[420,1023,867],{"class":430},[420,1025,971],{"class":474},[420,1027,974],{"class":489},[420,1029,977],{"class":430},[420,1031,1032],{"class":489}," anonymous",[420,1034,493],{"class":430},[420,1036,552],{"class":551},[420,1038,438],{"class":430},[420,1040,563],{"class":489},[420,1042,1044],{"class":422,"line":1043},9,[420,1045,998],{"class":430},[420,1047,1049,1051],{"class":422,"line":1048},10,[420,1050,560],{"class":430},[420,1052,563],{"class":434},[399,1054,1055,1056,1058,1059,1061,1062,1064],{},"Hooks fire after the session is resolved and ",[402,1057,407],{}," has set its fields. They run on every request that passes the ",[402,1060,645],{},"\u002F",[402,1063,625],{}," filter, so keep them fast and side-effect-free.",[1066,1067,1068,1073],"tip",{},[399,1069,1070,1071,493],{},"Common patterns for ",[402,1072,664],{},[1074,1075,1076,1080,1083],"ul",{},[1077,1078,1079],"li",{},"Force-keep audit logs for admins or high-value plans.",[1077,1081,1082],{},"Tag the request with feature flags or tenant info loaded from the session.",[1077,1084,1085],{},"Increment a per-user counter for billing.",[579,1087,1089],{"id":1088},"error-handling","Error Handling",[399,1091,1092,1093,1096,1097,850,1099,1102],{},"The middleware catches every error from ",[402,1094,1095],{},"getSession"," and logs nothing — your request keeps flowing whether the auth backend is up or down. The wide event still includes ",[402,1098,576],{},[402,1100,1101],{},"auth.identified: false"," so you can alert on session resolution health from your dashboards.",[1104,1105,1106],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}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 .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}",{"title":416,"searchDepth":454,"depth":454,"links":1108},[1109,1110,1111,1112],{"id":581,"depth":454,"text":85},{"id":698,"depth":454,"text":699},{"id":870,"depth":454,"text":871},{"id":1088,"depth":454,"text":1089},"Framework-agnostic factory with route filtering, session timing, and lifecycle hooks. Call it once at startup and reuse across requests.","md",[1116,1119],{"label":109,"icon":112,"to":110,"color":1117,"variant":1118},"neutral","subtle",{"label":123,"icon":126,"to":124,"color":1117,"variant":1118},{},{"title":114,"icon":117},{"title":394,"description":1113},"ZixjaO8WGr0DIrrPIzupQI4fZZLVn2bM3EBBAoqYgdg",[1125,1127],{"title":109,"path":110,"stem":111,"description":1126,"icon":112,"children":-1},"The core building block — extract safe user fields, mask emails, and capture plugin data (organizations, roles, 2FA) from a Better Auth session.",{"title":119,"path":120,"stem":121,"description":1128,"icon":69,"children":-1},"Mirror the server-side user identity into client-side logs by watching the Better Auth session and calling setIdentity.",1778106401226]