[{"data":1,"prerenderedAt":728},["ShallowReactive",2],{"docs-nav":3,"docs-\u002Fdocs\u002Fgetting-started":70},[4,10,14,19,23,26,29,33,36,40,43,47,50,54,58,62,66],{"title":5,"path":6,"order":7,"section":8,"group":9},"Concepts","\u002Fdocs\u002Fapi\u002Fconcepts",1,"api",null,{"title":11,"path":12,"order":7,"section":13,"group":9},"Introduction","\u002Fdocs","general",{"title":15,"path":16,"order":7,"section":17,"group":18},"Usage","\u002Fdocs\u002Fsdk\u002Fusage","sdk","Script",{"title":20,"path":21,"order":22,"section":8,"group":9},"\u002Fv1\u002Fme","\u002Fdocs\u002Fapi\u002Fme",2,{"title":24,"path":25,"order":22,"section":13,"group":9},"Getting started","\u002Fdocs\u002Fgetting-started",{"title":24,"path":27,"order":22,"section":17,"group":28},"\u002Fdocs\u002Fsdk\u002Fpackage","Package",{"title":30,"path":31,"order":32,"section":8,"group":9},"\u002Fv1\u002Fsubscribe","\u002Fdocs\u002Fapi\u002Fsubscribe",3,{"title":34,"path":35,"order":32,"section":17,"group":28},"Browser client","\u002Fdocs\u002Fsdk\u002Fpackage\u002Fclient",{"title":37,"path":38,"order":39,"section":8,"group":9},"\u002Fv1\u002Funsubscribe","\u002Fdocs\u002Fapi\u002Funsubscribe",4,{"title":41,"path":42,"order":39,"section":17,"group":28},"Server client","\u002Fdocs\u002Fsdk\u002Fpackage\u002Fserver",{"title":44,"path":45,"order":46,"section":8,"group":9},"\u002Fv1\u002Fevents","\u002Fdocs\u002Fapi\u002Fevents",5,{"title":48,"path":49,"order":46,"section":17,"group":28},"Types","\u002Fdocs\u002Fsdk\u002Fpackage\u002Ftypes",{"title":51,"path":52,"order":53,"section":8,"group":9},"\u002Fv1\u002Fsend","\u002Fdocs\u002Fapi\u002Fsend",6,{"title":55,"path":56,"order":57,"section":8,"group":9},"\u002Fv1\u002Fbroadcasts","\u002Fdocs\u002Fapi\u002Fbroadcasts",7,{"title":59,"path":60,"order":61,"section":8,"group":9},"\u002Fv1\u002Fgroups","\u002Fdocs\u002Fapi\u002Fgroups",8,{"title":63,"path":64,"order":65,"section":8,"group":9},"\u002Fv1\u002Fsubscribers","\u002Fdocs\u002Fapi\u002Fsubscribers",9,{"title":67,"path":68,"order":69,"section":8,"group":9},"Webhooks","\u002Fdocs\u002Fapi\u002Fwebhooks",10,{"id":71,"title":24,"apiModule":9,"body":72,"description":720,"extension":721,"generated":722,"group":9,"meta":723,"navigation":724,"order":22,"path":25,"section":13,"seo":725,"stem":726,"__hash__":727},"docs\u002Fdocs\u002Fgetting-started.md",{"type":73,"value":74,"toc":712},"minimark",[75,79,83,127,132,142,157,169,172,208,212,219,302,305,309,316,324,327,331,334,548,566,572,576,579,642,645,677,684,688,708],[76,77,24],"h1",{"id":78},"getting-started",[80,81,82],"p",{},"The whole flow, from zero to a notification appearing in your browser, is five steps.",[84,85,86],"blockquote",{},[80,87,88,92,93,97,98,107,108,111,112,115,116,119,120,123,124,126],{},[89,90,91],"strong",{},"New here? Try it before you wire anything up."," Run the full\nsubscribe → push → click loop in your browser first: create your project with\n",[94,95,96],"code",{},"tester.litepush.dev"," as its origin, paste its Project ID + VAPID public key\ninto the hosted tester at ",[99,100,105],"a",{"href":101,"target":102,"rel":103},"https:\u002F\u002Ftester.litepush.dev","_blank",[104],"noopener",[89,106,96],{},",\nhit ",[89,109,110],{},"Subscribe",", and send yourself a push (step 5). Once you've seen it work,\n",[89,113,114],{},"unsubscribe in the tester"," (or delete the test subscriber from the\n",[89,117,118],{},"Subscribers"," tab) so your test device isn't in your real audience — then\nchange the origin to your real domain in ",[89,121,122],{},"Settings → General"," and drop the\nSDK into your site (steps 2–4). The tester only subscribes for a project whose\norigin is ",[94,125,96],{}," — the same origin setting your real site will use.",[128,129,131],"h2",{"id":130},"_1-create-your-account","1. Create your account",[80,133,134,135,141],{},"Go to ",[99,136,140],{"href":137,"rel":138},"https:\u002F\u002Flitepush.dev\u002Fsignup",[139],"nofollow","litepush.dev\u002Fsignup"," and enter your email. We'll send an auth link — no password.",[80,143,144,145,148,149,152,153,156],{},"Once you're in, click ",[89,146,147],{},"New project",", give it a name (e.g. ",[94,150,151],{},"my-blog","), and set the origin to the public hostname where your SDK will run (e.g. ",[94,154,155],{},"myblog.com",").",[84,158,159],{},[80,160,161,164,165,168],{},[89,162,163],{},"Local development:"," the API does not accept ",[94,166,167],{},"http:\u002F\u002Flocalhost"," as a project origin. To test the SDK against the API from your device, expose your dev server through a tunnel (e.g. Cloudflare Tunnel or ngrok) and register the tunnel's HTTPS hostname as your project's origin.",[80,170,171],{},"You'll see three things on the project's overview page:",[173,174,175,185,195],"ul",{},[176,177,178,181,182],"li",{},[89,179,180],{},"Project ID"," — ",[94,183,184],{},"prj_xxxxxxxx",[176,186,187,190,191,194],{},[89,188,189],{},"VAPID public key"," — the public half of the keypair we generated for your project. You can rotate it later from ",[89,192,193],{},"Settings → Rotate VAPID keys",", but doing so invalidates every active subscription, so only rotate if the key is compromised or you want a fresh start.",[176,196,197,181,200,203,204,207],{},[89,198,199],{},"API key",[94,201,202],{},"lpk_live_xxxxxxxx",", shown ",[89,205,206],{},"once"," at creation. Copy it now; we only store the SHA-256 hash and can't recover the plaintext.",[128,209,211],{"id":210},"_2-drop-the-sdk-into-your-site","2. Drop the SDK into your site",[80,213,214,215,218],{},"Paste this ",[94,216,217],{},"\u003Cscript>"," tag on every page where you want to register subscribers:",[220,221,226],"pre",{"className":222,"code":223,"language":224,"meta":225,"style":225},"language-html shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003Cscript\n  src=\"https:\u002F\u002Flitepush.dev\u002Fsdk.js\"\n  data-project=\"prj_xxxxxxxx\"\n  data-vapid-key=\"BL9...your-public-key\"\n  async\n>\u003C\u002Fscript>\n","html","",[94,227,228,240,259,272,286,291],{"__ignoreMap":225},[229,230,232,236],"span",{"class":231,"line":7},"line",[229,233,235],{"class":234},"sMK4o","\u003C",[229,237,239],{"class":238},"swJcz","script\n",[229,241,242,246,249,252,256],{"class":231,"line":22},[229,243,245],{"class":244},"spNyl","  src",[229,247,248],{"class":234},"=",[229,250,251],{"class":234},"\"",[229,253,255],{"class":254},"sfazB","https:\u002F\u002Flitepush.dev\u002Fsdk.js",[229,257,258],{"class":234},"\"\n",[229,260,261,264,266,268,270],{"class":231,"line":32},[229,262,263],{"class":244},"  data-project",[229,265,248],{"class":234},[229,267,251],{"class":234},[229,269,184],{"class":254},[229,271,258],{"class":234},[229,273,274,277,279,281,284],{"class":231,"line":39},[229,275,276],{"class":244},"  data-vapid-key",[229,278,248],{"class":234},[229,280,251],{"class":234},[229,282,283],{"class":254},"BL9...your-public-key",[229,285,258],{"class":234},[229,287,288],{"class":231,"line":46},[229,289,290],{"class":244},"  async\n",[229,292,293,296,299],{"class":231,"line":53},[229,294,295],{"class":234},">\u003C\u002F",[229,297,298],{"class":238},"script",[229,300,301],{"class":234},">\n",[80,303,304],{},"The overview page generates this snippet with your project's values pre-filled — just hit the copy button.",[128,306,308],{"id":307},"_3-add-the-service-worker","3. Add the service worker",[80,310,311,312,315],{},"LitePush needs a service worker on your origin to receive push messages while the browser tab is closed. Download the pre-built worker from your project's overview page (or directly at ",[94,313,314],{},"litepush.dev\u002Flitepush-sw.js",") and serve it at your site root:",[220,317,322],{"className":318,"code":320,"language":321},[319],"language-text","https:\u002F\u002Fmyblog.com\u002Flitepush-sw.js\n","text",[94,323,320],{"__ignoreMap":225},[80,325,326],{},"The SDK auto-registers it for you on first call.",[128,328,330],{"id":329},"_4-ask-the-visitor-to-subscribe","4. Ask the visitor to subscribe",[80,332,333],{},"From your page (after a click — browsers require a user gesture):",[220,335,339],{"className":336,"code":337,"language":338,"meta":225,"style":225},"language-js shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","document.getElementById(\"subscribe-btn\").addEventListener(\"click\", async () => {\n  const result = await litepush.subscribe({\n    userId: currentUser.id, \u002F\u002F optional — your own user id\n  });\n  if (result) {\n    console.log(\"Subscribed:\", result.id);\n  } else {\n    console.warn(\"User denied notification permission.\");\n  }\n});\n","js",[94,340,341,396,424,446,456,472,503,512,534,539],{"__ignoreMap":225},[229,342,343,347,350,354,357,359,362,364,367,369,372,374,376,379,381,384,387,390,393],{"class":231,"line":7},[229,344,346],{"class":345},"sTEyZ","document",[229,348,349],{"class":234},".",[229,351,353],{"class":352},"s2Zo4","getElementById",[229,355,356],{"class":345},"(",[229,358,251],{"class":234},[229,360,361],{"class":254},"subscribe-btn",[229,363,251],{"class":234},[229,365,366],{"class":345},")",[229,368,349],{"class":234},[229,370,371],{"class":352},"addEventListener",[229,373,356],{"class":345},[229,375,251],{"class":234},[229,377,378],{"class":254},"click",[229,380,251],{"class":234},[229,382,383],{"class":234},",",[229,385,386],{"class":244}," async",[229,388,389],{"class":234}," ()",[229,391,392],{"class":244}," =>",[229,394,395],{"class":234}," {\n",[229,397,398,401,404,407,411,414,416,419,421],{"class":231,"line":22},[229,399,400],{"class":244},"  const",[229,402,403],{"class":345}," result",[229,405,406],{"class":234}," =",[229,408,410],{"class":409},"s7zQu"," await",[229,412,413],{"class":345}," litepush",[229,415,349],{"class":234},[229,417,418],{"class":352},"subscribe",[229,420,356],{"class":238},[229,422,423],{"class":234},"{\n",[229,425,426,429,432,435,437,440,442],{"class":231,"line":32},[229,427,428],{"class":238},"    userId",[229,430,431],{"class":234},":",[229,433,434],{"class":345}," currentUser",[229,436,349],{"class":234},[229,438,439],{"class":345},"id",[229,441,383],{"class":234},[229,443,445],{"class":444},"sHwdD"," \u002F\u002F optional — your own user id\n",[229,447,448,451,453],{"class":231,"line":39},[229,449,450],{"class":234},"  }",[229,452,366],{"class":238},[229,454,455],{"class":234},";\n",[229,457,458,461,464,467,470],{"class":231,"line":46},[229,459,460],{"class":409},"  if",[229,462,463],{"class":238}," (",[229,465,466],{"class":345},"result",[229,468,469],{"class":238},") ",[229,471,423],{"class":234},[229,473,474,477,479,482,484,486,489,491,493,495,497,499,501],{"class":231,"line":53},[229,475,476],{"class":345},"    console",[229,478,349],{"class":234},[229,480,481],{"class":352},"log",[229,483,356],{"class":238},[229,485,251],{"class":234},[229,487,488],{"class":254},"Subscribed:",[229,490,251],{"class":234},[229,492,383],{"class":234},[229,494,403],{"class":345},[229,496,349],{"class":234},[229,498,439],{"class":345},[229,500,366],{"class":238},[229,502,455],{"class":234},[229,504,505,507,510],{"class":231,"line":57},[229,506,450],{"class":234},[229,508,509],{"class":409}," else",[229,511,395],{"class":234},[229,513,514,516,518,521,523,525,528,530,532],{"class":231,"line":61},[229,515,476],{"class":345},[229,517,349],{"class":234},[229,519,520],{"class":352},"warn",[229,522,356],{"class":238},[229,524,251],{"class":234},[229,526,527],{"class":254},"User denied notification permission.",[229,529,251],{"class":234},[229,531,366],{"class":238},[229,533,455],{"class":234},[229,535,536],{"class":231,"line":65},[229,537,538],{"class":234},"  }\n",[229,540,541,544,546],{"class":231,"line":69},[229,542,543],{"class":234},"}",[229,545,366],{"class":345},[229,547,455],{"class":234},[80,549,550,553,554,557,558,561,562,565],{},[94,551,552],{},"subscribe()"," returns ",[94,555,556],{},"{ id }"," on success or ",[94,559,560],{},"null"," if the user denied permission. It throws if the browser doesn't support web push — call ",[94,563,564],{},"litepush.canSubscribe()"," first if you want to gate the button.",[80,567,568,569,571],{},"That's it on the client side. You'll see the subscriber appear in your dashboard's ",[89,570,118],{}," tab within seconds.",[128,573,575],{"id":574},"_5-send-a-notification","5. Send a notification",[80,577,578],{},"From your server (Node \u002F Bun \u002F Deno \u002F anything that can POST):",[220,580,584],{"className":581,"code":582,"language":583,"meta":225,"style":225},"language-sh shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","curl -X POST https:\u002F\u002Fapi.litepush.dev\u002Fv1\u002Fsend \\\n  -H \"Authorization: Bearer lpk_live_xxxxxxxx\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"target\": { \"type\": \"all\" },\n    \"notification\": {\n      \"title\": \"New post on the blog\",\n      \"body\": \"We just shipped Web Push support — read more\",\n      \"url\": \"https:\u002F\u002Fmyblog.com\u002Fposts\u002Fweb-push\"\n    }\n  }'\n","sh",[94,585,586,591,596,601,606,611,616,621,626,631,636],{"__ignoreMap":225},[229,587,588],{"class":231,"line":7},[229,589,590],{},"curl -X POST https:\u002F\u002Fapi.litepush.dev\u002Fv1\u002Fsend \\\n",[229,592,593],{"class":231,"line":22},[229,594,595],{},"  -H \"Authorization: Bearer lpk_live_xxxxxxxx\" \\\n",[229,597,598],{"class":231,"line":32},[229,599,600],{},"  -H \"Content-Type: application\u002Fjson\" \\\n",[229,602,603],{"class":231,"line":39},[229,604,605],{},"  -d '{\n",[229,607,608],{"class":231,"line":46},[229,609,610],{},"    \"target\": { \"type\": \"all\" },\n",[229,612,613],{"class":231,"line":53},[229,614,615],{},"    \"notification\": {\n",[229,617,618],{"class":231,"line":57},[229,619,620],{},"      \"title\": \"New post on the blog\",\n",[229,622,623],{"class":231,"line":61},[229,624,625],{},"      \"body\": \"We just shipped Web Push support — read more\",\n",[229,627,628],{"class":231,"line":65},[229,629,630],{},"      \"url\": \"https:\u002F\u002Fmyblog.com\u002Fposts\u002Fweb-push\"\n",[229,632,633],{"class":231,"line":69},[229,634,635],{},"    }\n",[229,637,639],{"class":231,"line":638},11,[229,640,641],{},"  }'\n",[80,643,644],{},"Response:",[220,646,650],{"className":647,"code":648,"language":649,"meta":225,"style":225},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{ \"broadcast_id\": \"bdc_01HXM...\" }\n","json",[94,651,652],{"__ignoreMap":225},[229,653,654,657,660,663,665,667,669,672,674],{"class":231,"line":7},[229,655,656],{"class":234},"{",[229,658,659],{"class":234}," \"",[229,661,662],{"class":244},"broadcast_id",[229,664,251],{"class":234},[229,666,431],{"class":234},[229,668,659],{"class":234},[229,670,671],{"class":254},"bdc_01HXM...",[229,673,251],{"class":234},[229,675,676],{"class":234}," }\n",[80,678,679,680,683],{},"The notification fans out asynchronously. Watch the broadcast's ",[89,681,682],{},"Delivered"," counter in the dashboard tick up.",[128,685,687],{"id":686},"what-next","What next?",[173,689,690,697,702],{},[176,691,692,693,349],{},"Want to target a subset of subscribers? Read ",[99,694,695],{"href":60},[94,696,59],{},[176,698,699,700,349],{},"Want your server to be notified when a user clicks the push? Read ",[99,701,67],{"href":68},[176,703,704,705,349],{},"Want to integrate from your backend? Start with ",[99,706,707],{"href":6},"API concepts",[709,710,711],"style",{},"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 .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}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 .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}",{"title":225,"searchDepth":22,"depth":22,"links":713},[714,715,716,717,718,719],{"id":130,"depth":22,"text":131},{"id":210,"depth":22,"text":211},{"id":307,"depth":22,"text":308},{"id":329,"depth":22,"text":330},{"id":574,"depth":22,"text":575},{"id":686,"depth":22,"text":687},"Sign up, drop the SDK in, send your first notification — five minutes end to end.","md",false,{},true,{"title":24,"description":720},"docs\u002Fgetting-started","wNIWPh9Rhzs4irTQFXa_rV-Cn8t1ASK8u8vlbXKTPqk",1780560203629]