[{"data":1,"prerenderedAt":650},["ShallowReactive",2],{"navigation":3,"\u002Frecipes\u002Fdeploy":208,"\u002Frecipes\u002Fdeploy-surround":645},[4,98,175],{"title":5,"path":6,"stem":7,"children":8,"icon":97},"Guide","\u002Fguide","1.guide\u002F1.index",[9,12,17,22,46,61,79],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-house",{"title":13,"path":14,"stem":15,"icon":16},"Installation","\u002Fguide\u002Finstallation","1.guide\u002F2.installation","i-lucide-download",{"title":18,"path":19,"stem":20,"icon":21},"Quick start","\u002Fguide\u002Fquick-start","1.guide\u002F3.quick-start","i-lucide-rocket",{"title":23,"path":24,"stem":25,"children":26,"icon":45},"Server","\u002Fguide\u002Fserver","1.guide\u002F4.server\u002F1.index",[27,30,35,40],{"title":28,"path":24,"stem":25,"icon":29},"Usage","i-lucide-server",{"title":31,"path":32,"stem":33,"icon":34},"Config file","\u002Fguide\u002Fserver\u002Fconfig-file","1.guide\u002F4.server\u002F2.config-file","i-lucide-file-cog",{"title":36,"path":37,"stem":38,"icon":39},"Options","\u002Fguide\u002Fserver\u002Foptions","1.guide\u002F4.server\u002F3.options","i-lucide-settings",{"title":41,"path":42,"stem":43,"icon":44},"Advanced","\u002Fguide\u002Fserver\u002Fadvanced","1.guide\u002F4.server\u002F4.advanced","i-lucide-flask-conical",false,{"title":47,"path":48,"stem":49,"children":50,"icon":45},"Client","\u002Fguide\u002Fclient","1.guide\u002F5.client\u002F1.index",[51,53,58],{"title":28,"path":48,"stem":49,"icon":52},"i-lucide-monitor-smartphone",{"title":54,"path":55,"stem":56,"icon":57},"Live queries","\u002Fguide\u002Fclient\u002Flive-queries","1.guide\u002F5.client\u002F2.live-queries","i-lucide-radio",{"title":41,"path":59,"stem":60,"icon":44},"\u002Fguide\u002Fclient\u002Fadvanced","1.guide\u002F5.client\u002F3.advanced",{"title":62,"path":63,"stem":64,"children":65,"icon":45},"Development socket","\u002Fguide\u002Fsocket","1.guide\u002F6.socket\u002F1.index",[66,68,71,74],{"title":28,"path":63,"stem":64,"icon":67},"i-lucide-plug",{"title":36,"path":69,"stem":70,"icon":39},"\u002Fguide\u002Fsocket\u002Foptions","1.guide\u002F6.socket\u002F2.options",{"title":41,"path":72,"stem":73,"icon":44},"\u002Fguide\u002Fsocket\u002Fadvanced","1.guide\u002F6.socket\u002F3.advanced",{"title":75,"path":76,"stem":77,"icon":78},"PGlite in dev, Postgres in prod","\u002Fguide\u002Fsocket\u002Fdevelopment-only","1.guide\u002F6.socket\u002F4.development-only","i-lucide-cloud-upload",{"title":80,"path":81,"stem":82,"children":83,"icon":45},"DevTools & tooling","\u002Fguide\u002Fdevtools","1.guide\u002F7.devtools\u002F1.index",[84,87,92],{"title":85,"path":81,"stem":82,"icon":86},"DevTools tab","i-lucide-wrench",{"title":88,"path":89,"stem":90,"icon":91},"Actions","\u002Fguide\u002Fdevtools\u002Factions","1.guide\u002F7.devtools\u002F2.actions","i-lucide-zap",{"title":93,"path":94,"stem":95,"icon":96},"Terminal","\u002Fguide\u002Fdevtools\u002Fterminal","1.guide\u002F7.devtools\u002F3.terminal","i-lucide-square-terminal","i-lucide-book-open",{"title":99,"icon":100,"path":101,"stem":102,"children":103,"page":45},"Recipes","i-lucide-chef-hat","\u002Frecipes","2.recipes",[104,116,138,159,171],{"title":105,"path":106,"stem":107,"children":108,"icon":45},"Migrations","\u002Frecipes\u002Fmigrations","2.recipes\u002F1.migrations\u002F1.index",[109,111],{"title":28,"path":106,"stem":107,"icon":110},"i-lucide-database-backup",{"title":112,"path":113,"stem":114,"icon":115},"Edited migrations","\u002Frecipes\u002Fmigrations\u002Fedited-migrations","2.recipes\u002F1.migrations\u002F2.edited-migrations","i-lucide-file-diff",{"title":117,"path":118,"stem":119,"children":120,"icon":45},"Testing","\u002Frecipes\u002Ftesting","2.recipes\u002F2.testing\u002F1.index",[121,123,128,133],{"title":28,"path":118,"stem":119,"icon":122},"i-lucide-test-tube",{"title":124,"path":125,"stem":126,"icon":127},"Isolation","\u002Frecipes\u002Ftesting\u002Fisolation","2.recipes\u002F2.testing\u002F2.isolation","i-lucide-git-fork",{"title":129,"path":130,"stem":131,"icon":132},"vitest","\u002Frecipes\u002Ftesting\u002Fvitest","2.recipes\u002F2.testing\u002F3.vitest","i-simple-icons-vitest",{"title":134,"path":135,"stem":136,"icon":137},"@nuxt\u002Ftest-utils","\u002Frecipes\u002Ftesting\u002Fnuxt-test-utils","2.recipes\u002F2.testing\u002F4.nuxt-test-utils","i-simple-icons-nuxt",{"title":139,"path":140,"stem":141,"children":142,"icon":45},"Deploy","\u002Frecipes\u002Fdeploy","2.recipes\u002F3.deploy\u002F1.index",[143,144,149,154],{"title":139,"path":140,"stem":141},{"title":145,"path":146,"stem":147,"icon":148},"Any Postgres","\u002Frecipes\u002Fdeploy\u002Fpostgres","2.recipes\u002F3.deploy\u002F2.postgres","i-lucide-database",{"title":150,"path":151,"stem":152,"icon":153},"Netlify","\u002Frecipes\u002Fdeploy\u002Fnetlify","2.recipes\u002F3.deploy\u002F3.netlify","i-simple-icons-netlify",{"title":155,"path":156,"stem":157,"icon":158},"Neon","\u002Frecipes\u002Fdeploy\u002Fneon","2.recipes\u002F3.deploy\u002F4.neon","i-simple-icons-neon",{"title":160,"path":161,"stem":162,"children":163,"icon":45},"Outside Nuxt","\u002Frecipes\u002Foutside-nuxt","2.recipes\u002F4.outside-nuxt\u002F1.index",[164,167],{"title":165,"path":161,"stem":162,"icon":166},"Config and provider","i-lucide-package",{"title":168,"path":169,"stem":170,"icon":67},"Socket server","\u002Frecipes\u002Foutside-nuxt\u002Fsocket","2.recipes\u002F4.outside-nuxt\u002F2.socket",{"title":172,"path":173,"stem":174,"icon":67},"Nitro's useDatabase","\u002Frecipes\u002Fnitro-database","2.recipes\u002F5.nitro-database",{"title":176,"icon":177,"path":178,"stem":179,"children":180,"page":45},"Reference","i-lucide-code-xml","\u002Freference","3.reference",[181,185,189,193,198,203],{"title":182,"path":183,"stem":184,"icon":34},"Config files","\u002Freference\u002Fconfig-files","3.reference\u002F1.config-files",{"title":186,"path":187,"stem":188,"icon":39},"Module options","\u002Freference\u002Fmodule-options","3.reference\u002F2.module-options",{"title":190,"path":191,"stem":192,"icon":67},"Socket options","\u002Freference\u002Fsocket-options","3.reference\u002F3.socket-options",{"title":194,"path":195,"stem":196,"icon":197},"Exports","\u002Freference\u002Fexports","3.reference\u002F4.exports","i-lucide-boxes",{"title":199,"path":200,"stem":201,"icon":202},"Hooks","\u002Freference\u002Fhooks","3.reference\u002F5.hooks","i-lucide-anchor",{"title":204,"path":205,"stem":206,"icon":207},"Environment","\u002Freference\u002Fenvironment","3.reference\u002F6.environment","i-lucide-variable",{"id":209,"title":139,"body":210,"description":634,"extension":635,"links":636,"meta":637,"navigation":638,"path":140,"seo":639,"stem":141,"__hash__":644},"docs\u002F2.recipes\u002F3.deploy\u002F1.index.md",{"type":211,"value":212,"toc":629},"minimark",[213,230,379,384,462,478,482,497,569,576,580,601,625],[214,215,216,217,220,221,224,225,229],"p",{},"The usual setup is the ",[218,219,75],"a",{"href":76}," one: the server side is disabled, the ",[218,222,223],{"href":63},"development socket"," serves PGlite while ",[226,227,228],"code",{},"nuxt dev"," runs, and production connects to a real Postgres. Your database code reads a connection string from the environment and uses an ordinary driver, so nothing changes between the two but the value of that variable.",[231,232,238],"pre",{"className":233,"code":234,"filename":235,"language":236,"meta":237,"style":237},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","export default defineNuxtConfig({\n  modules: ['nuxt-pglite'],\n  pglite: {\n    server: {\n      enabled: false, \u002F\u002F nothing of PGlite in the build\n    },\n    socket: { port: 5433 }, \u002F\u002F `DATABASE_URL` while `nuxt dev` runs\n  },\n})\n","nuxt.config.ts","ts","",[226,239,240,264,292,303,313,332,338,364,370],{"__ignoreMap":237},[241,242,245,249,252,256,260],"span",{"class":243,"line":244},"line",1,[241,246,248],{"class":247},"s7zQu","export",[241,250,251],{"class":247}," default",[241,253,255],{"class":254},"s2Zo4"," defineNuxtConfig",[241,257,259],{"class":258},"sTEyZ","(",[241,261,263],{"class":262},"sMK4o","{\n",[241,265,267,271,274,277,280,284,286,289],{"class":243,"line":266},2,[241,268,270],{"class":269},"swJcz","  modules",[241,272,273],{"class":262},":",[241,275,276],{"class":258}," [",[241,278,279],{"class":262},"'",[241,281,283],{"class":282},"sfazB","nuxt-pglite",[241,285,279],{"class":262},[241,287,288],{"class":258},"]",[241,290,291],{"class":262},",\n",[241,293,295,298,300],{"class":243,"line":294},3,[241,296,297],{"class":269},"  pglite",[241,299,273],{"class":262},[241,301,302],{"class":262}," {\n",[241,304,306,309,311],{"class":243,"line":305},4,[241,307,308],{"class":269},"    server",[241,310,273],{"class":262},[241,312,302],{"class":262},[241,314,316,319,321,325,328],{"class":243,"line":315},5,[241,317,318],{"class":269},"      enabled",[241,320,273],{"class":262},[241,322,324],{"class":323},"sfNiH"," false",[241,326,327],{"class":262},",",[241,329,331],{"class":330},"sHwdD"," \u002F\u002F nothing of PGlite in the build\n",[241,333,335],{"class":243,"line":334},6,[241,336,337],{"class":262},"    },\n",[241,339,341,344,346,349,352,354,358,361],{"class":243,"line":340},7,[241,342,343],{"class":269},"    socket",[241,345,273],{"class":262},[241,347,348],{"class":262}," {",[241,350,351],{"class":269}," port",[241,353,273],{"class":262},[241,355,357],{"class":356},"sbssI"," 5433",[241,359,360],{"class":262}," },",[241,362,363],{"class":330}," \u002F\u002F `DATABASE_URL` while `nuxt dev` runs\n",[241,365,367],{"class":243,"line":366},8,[241,368,369],{"class":262},"  },\n",[241,371,373,376],{"class":243,"line":372},9,[241,374,375],{"class":262},"}",[241,377,378],{"class":258},")\n",[380,381,383],"h2",{"id":382},"the-environment","The environment",[385,386,387,403],"table",{},[388,389,390],"thead",{},[391,392,393,396,400],"tr",{},[394,395],"th",{},[394,397,398],{},[226,399,228],{},[394,401,402],{},"Production",[404,405,406,420,435,448],"tbody",{},[391,407,408,414,417],{},[409,410,411],"td",{},[226,412,413],{},"DATABASE_URL",[409,415,416],{},"the socket's URL, unless already set",[409,418,419],{},"set by you, or by your platform",[391,421,422,425,432],{},[409,423,424],{},"Driver",[409,426,427,428,431],{},"yours (",[226,429,430],{},"pg",", postgres.js, Drizzle, …) over the wire protocol",[409,433,434],{},"the same",[391,436,437,442,445],{},[409,438,439],{},[226,440,441],{},"server\u002Fpglite.config.ts",[409,443,444],{},"loaded by the socket",[409,446,447],{},"not bundled",[391,449,450,456,459],{},[409,451,452,455],{},[226,453,454],{},"@electric-sql\u002Fpglite"," in the server output",[409,457,458],{},"n\u002Fa",[409,460,461],{},"absent",[214,463,464,466,467,473,474,477],{},[226,465,413],{}," is the socket's default variable, and the one most hosts and tools use. A platform that provisions the database itself may set another name: ",[218,468,470],{"href":469},"\u002Fguide\u002Fsocket#provider-presets",[226,471,472],{},"socket.provider"," exports that one instead, so code written for the platform reaches the socket unchanged. A variable already set in your environment always wins over the socket, so a ",[226,475,476],{},".env"," pointing at a real database is respected in development too.",[380,479,481],{"id":480},"the-two-migration-models","The two migration models",[214,483,484,485,488,489,492,493,496],{},"The schema comes from a ",[218,486,487],{"href":106},"folder of SQL migration files",". In development, ",[226,490,491],{},"init"," applies them to PGlite with ",[226,494,495],{},"applyMigrations",". In production, who applies them depends on the platform:",[385,498,499,511],{},[388,500,501],{},[391,502,503,505,508],{},[394,504],{},[394,506,507],{},"You apply",[394,509,510],{},"The platform applies",[404,512,513,524,552],{},[391,514,515,518,521],{},[409,516,517],{},"Where",[409,519,520],{},"the build command or a CI job, with the production URL",[409,522,523],{},"the platform, from the files committed with your app, on deploy",[391,525,526,529,541],{},[409,527,528],{},"How",[409,530,531,534,535,537,538],{},[226,532,533],{},"drizzle-kit migrate"," (or your tool's migrate), or ",[226,536,495],{}," with ",[226,539,540],{},"fromPool",[409,542,543,544,547,548,551],{},"nothing to run: commit the files where the platform reads them, and never ",[226,545,546],{},"push"," or ",[226,549,550],{},"migrate"," against its database",[391,553,554,557,564],{},[409,555,556],{},"Example",[409,558,559,561,562],{},[218,560,145],{"href":146},", ",[218,563,155],{"href":156},[409,565,566],{},[218,567,568],{"href":151},"Netlify Database",[214,570,571,572,575],{},"Either way, the local database and the production one are built from the same files, and a file edited after it was applied is ",[218,573,574],{"href":113},"caught locally"," before it reaches production.",[380,577,579],{"id":578},"pglite-in-production","PGlite in production",[214,581,582,583,587,588,594,595,597,598,600],{},"If you deploy with the server side ",[584,585,586],"strong",{},"enabled",", PGlite itself runs in production and needs a writable, persistent data directory: a Node server or a container with a volume, not a serverless function. Set it with ",[218,589,591],{"href":590},"\u002Fguide\u002Fserver\u002Foptions#runtime-overrides",[226,592,593],{},"NUXT_PGLITE_DATA_DIR",", and keep ",[226,596,495],{}," in ",[226,599,491],{}," pointed at a directory that exists at runtime.",[602,603,604,612,617],"card-group",{},[605,606,607],"card",{"icon":148,"title":145,"to":146},[214,608,609,611],{},[226,610,413],{}," and a migrate step in the build.",[605,613,614],{"icon":153,"title":150,"to":151},[214,615,616],{},"Netlify Database applies the committed files on deploy.",[605,618,619],{"icon":158,"title":155,"to":156},[214,620,621,622,624],{},"Serverless drivers in production, ",[226,623,430],{}," against the socket.",[626,627,628],"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 .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}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 .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}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);}",{"title":237,"searchDepth":244,"depth":266,"links":630},[631,632,633],{"id":382,"depth":266,"text":383},{"id":480,"depth":266,"text":481},{"id":578,"depth":266,"text":579},"[object Object]","md",null,{},true,{"title":139,"description":640},{"How development and production relate":641,"navigation":642},"PGlite behind the socket in nuxt dev, a real Postgres in production, the same code and the same migration files.",{"title":643,"icon":78},"Overview","9Ovym4AGS6f3GrQVaj5j84RS9HzhmKjsE_qLuy_f_CM",[646,648],{"title":134,"path":135,"stem":136,"description":647,"icon":137,"children":-1},"Boot the built app against a test database in an end-to-end suite, with the variables handed to setup().",{"title":145,"path":146,"stem":147,"description":649,"icon":148,"children":-1},"Deploy against a Postgres reached through DATABASE_URL, on any host Nitro supports, with the migrations applied from the build or CI.",1791474259253]