[{"data":1,"prerenderedAt":133},["ShallowReactive",2],{"docs:\u002Fdocs\u002Fwhy-nuxt-endpoints":3,"i-lucide:moon":124,"i-lucide:github":129,"i-lucide:menu":131},{"id":4,"title":5,"body":6,"description":116,"extension":117,"meta":118,"navigation":119,"path":120,"seo":121,"stem":122,"__hash__":123},"docs\u002Fdocs\u002Fwhy-nuxt-endpoints.md","Why Nuxt Endpoints?",{"type":7,"value":8,"toc":109},"minimark",[9,14,18,54,57,61,64,67,78,82,93],[10,11,13],"h2",{"id":12},"the-problem","The problem",[15,16,17],"p",{},"In a plain Nuxt app, your server routes and your client calls drift apart:",[19,20,21,37,51],"ul",{},[22,23,24,28,29,32,33,36],"li",{},[25,26,27],"code",{},"getQuery"," \u002F ",[25,30,31],{},"readBody"," give you ",[25,34,35],{},"unknown","-ish data — nothing validates the request before your handler runs.",[22,38,39,42,43,47,48,50],{},[25,40,41],{},"$fetch"," infers the ",[44,45,46],"em",{},"serialized return type",", but request params, query, and bodies are untyped, and error responses are ",[25,49,35],{},".",[22,52,53],{},"If you need OpenAPI for external consumers, you maintain it by hand — and it silently goes stale.",[15,55,56],{},"Each of these can be patched individually: a validation call at the top of the handler, a hand-written request type on the client, a spec file updated in review. But the patches are not connected to each other, so nothing fails when they disagree. The drift is silent.",[10,58,60],{"id":59},"the-idea","The idea",[15,62,63],{},"Define the HTTP contract once, next to the handler, with the schema library you already use. Everything else — runtime validation, the typed client, the OpenAPI document — is derived from that single definition.",[15,65,66],{},"Because every surface is generated from the same source, they cannot disagree:",[19,68,69,72,75],{},[22,70,71],{},"The handler only runs after the request matched the contract, and its return values are type-checked against the declared responses.",[22,73,74],{},"The client types are computed from the contract at build time, including error branches and the JSON wire representation.",[22,76,77],{},"The OpenAPI document is regenerated from the contract, so it is always as current as the code.",[10,79,81],{"id":80},"what-this-deliberately-is-not","What this deliberately is not",[15,83,84,85,88,89,92],{},"The contract wraps plain HTTP routes instead of replacing them. Endpoints stay ordinary files under ",[25,86,87],{},"server\u002Fapi",", callable by mobile apps, other services, or ",[25,90,91],{},"curl"," — there is no custom protocol and no lock-in on the wire. Adoption is per-route, and removing a definition returns the route to a plain Nuxt handler.",[15,94,95,96,98,99,104,105,50],{},"For a detailed positioning against plain ",[25,97,41],{}," typing, tRPC, and spec-first codegen, see ",[100,101,103],"a",{"href":102},"\u002Fdocs\u002Fcomparison","Comparison",". For how the pieces fit together, see the ",[100,106,108],{"href":107},"\u002Fdocs\u002Fmental-model","Mental Model",{"title":110,"searchDepth":111,"depth":111,"links":112},"",2,[113,114,115],{"id":12,"depth":111,"text":13},{"id":59,"depth":111,"text":60},{"id":80,"depth":111,"text":81},"The drift problem in plain Nuxt apps, and the single-contract idea behind the module.","md",{},true,"\u002Fdocs\u002Fwhy-nuxt-endpoints",{"title":5,"description":116},"docs\u002Fwhy-nuxt-endpoints","gzmYpyIsGu14bcaY0kskETPnPhdUzq-1m427JiAcpJk",{"left":125,"top":125,"width":126,"height":126,"rotate":125,"vFlip":127,"hFlip":127,"body":128},0,24,false,"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\"\u002F>",{"left":125,"top":125,"width":126,"height":126,"rotate":125,"vFlip":127,"hFlip":127,"body":130,"hidden":119},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5c.08-1.25-.27-2.48-1-3.5c.28-1.15.28-2.35 0-3.5c0 0-1 0-3 1.5c-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.4 5.4 0 0 0 4 9c0 3.5 3 5.5 6 5.5c-.39.49-.68 1.05-.85 1.65S8.93 17.38 9 18v4\"\u002F>\u003Cpath d=\"M9 18c-4.51 2-5-2-7-2\"\u002F>\u003C\u002Fg>",{"left":125,"top":125,"width":126,"height":126,"rotate":125,"vFlip":127,"hFlip":127,"body":132},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 5h16M4 12h16M4 19h16\"\u002F>",1787723882391]