[{"data":1,"prerenderedAt":2180},["ShallowReactive",2],{"docsNavigation":3,"contentNavigation":145,"\u002Fblog\u002Fpolar-checkout-customer-portal-better-auth-nuxt":229,"\u002Fblog\u002Fpolar-checkout-customer-portal-better-auth-nuxt-blog-surround":2173,"$f1wh79sv3cs7lu":2177},[4,32,44,52,60,67,75,83,90,97,104,112,119,127,139],{"title":5,"path":6,"stem":7,"children":8,"icon":31},"Getting Started","\u002Fdocs\u002Fgetting-started","docs\u002F01.getting-started\u002F1.index",[9,11,15,19,23,27],{"title":10,"path":6,"stem":7},"Introduction",{"title":12,"path":13,"stem":14},"Installation","\u002Fdocs\u002Fgetting-started\u002Finstallation","docs\u002F01.getting-started\u002F2.installation",{"title":16,"path":17,"stem":18},"Setup","\u002Fdocs\u002Fgetting-started\u002Fsetup","docs\u002F01.getting-started\u002F3.setup",{"title":20,"path":21,"stem":22},"Pull Updates","\u002Fdocs\u002Fgetting-started\u002Fpull-updates","docs\u002F01.getting-started\u002F4.pull-updates",{"title":24,"path":25,"stem":26},"Deployment","\u002Fdocs\u002Fgetting-started\u002Fdeployment","docs\u002F01.getting-started\u002F5.deployment",{"title":28,"path":29,"stem":30},"Going to production","\u002Fdocs\u002Fgetting-started\u002Fgoing-to-production","docs\u002F01.getting-started\u002F6.going-to-production","i-lucide-square-play",{"title":33,"path":34,"stem":35,"children":36,"icon":43},"Architecture","\u002Fdocs\u002Farchitecture","docs\u002F02.architecture\u002F1.index",[37,39],{"title":38,"path":34,"stem":35},"Tech Stack",{"title":40,"path":41,"stem":42},"Layers","\u002Fdocs\u002Farchitecture\u002Flayers","docs\u002F02.architecture\u002F2.layers","i-lucide-layers",{"title":45,"path":46,"stem":47,"children":48,"icon":51},"Database","\u002Fdocs\u002Fdatabase","docs\u002F03.database\u002F1.index",[49],{"title":50,"path":46,"stem":47},"PostgreSQL","i-lucide-database",{"title":53,"path":54,"stem":55,"children":56,"icon":59},"Emails","\u002Fdocs\u002Femails","docs\u002F04.emails\u002F1.index",[57],{"title":58,"path":54,"stem":55},"Overview","i-lucide-mail",{"title":61,"path":62,"stem":63,"children":64,"icon":66},"Authentication","\u002Fdocs\u002Fauthentication","docs\u002F05.authentication\u002F1.index",[65],{"title":58,"path":62,"stem":63},"i-lucide-lock-keyhole",{"title":68,"path":69,"stem":70,"children":71,"icon":74},"Payments","\u002Fdocs\u002Fpayments","docs\u002F06.payments\u002F1.index",[72],{"title":73,"path":69,"stem":70},"Polar","i-lucide-circle-dollar-sign",{"title":76,"path":77,"stem":78,"children":79,"icon":82},"Admin","\u002Fdocs\u002Fadmin","docs\u002F07.admin\u002F1.index",[80],{"title":81,"path":77,"stem":78},"Features","i-lucide-user-cog",{"title":84,"path":85,"stem":86,"children":87,"icon":89},"Images","\u002Fdocs\u002Fimages","docs\u002F08.images\u002F1.index",[88],{"title":58,"path":85,"stem":86},"i-lucide-image",{"title":91,"path":92,"stem":93,"children":94,"icon":96},"i18n","\u002Fdocs\u002Fi18n","docs\u002F09.i18n\u002F1.index",[95],{"title":58,"path":92,"stem":93},"i-lucide-languages",{"title":98,"path":99,"stem":100,"children":101,"icon":103},"SEO","\u002Fdocs\u002Fseo","docs\u002F10.seo\u002F1.index",[102],{"title":58,"path":99,"stem":100},"i-lucide-globe",{"title":105,"path":106,"stem":107,"children":108,"icon":111},"Analytics","\u002Fdocs\u002Fanalytics","docs\u002F11.analytics\u002F1.index",[109],{"title":110,"path":106,"stem":107},"Umami","i-lucide-chart-line",{"title":113,"path":114,"stem":115,"children":116,"icon":118},"Security","\u002Fdocs\u002Fsecurity","docs\u002F12.security\u002F1.index",[117],{"title":58,"path":114,"stem":115},"i-lucide-file-lock",{"title":120,"path":121,"stem":122,"children":123,"icon":126},"Testing","\u002Fdocs\u002Ftesting","docs\u002F13.testing\u002F1.index",[124],{"title":125,"path":121,"stem":122},"E2E Testing","i-lucide-test-tube",{"title":128,"path":129,"stem":130,"children":131,"icon":138},"Support","\u002Fdocs\u002Fsupport","docs\u002F14.support\u002F1.index",[132,134],{"title":133,"path":129,"stem":130},"Help",{"title":135,"path":136,"stem":137},"Troubleshooting","\u002Fdocs\u002Fsupport\u002Ftroubleshooting","docs\u002F14.support\u002F2.troubleshooting","i-lucide-message-circle-question",{"title":140,"path":141,"stem":142,"children":143},"LLMs","\u002Fdocs\u002Fllms","docs\u002F15.llms\u002F1.index",[144],{"title":140,"path":141,"stem":142},[146,172],{"title":147,"path":148,"stem":149,"children":150,"page":171},"Blog","\u002Fblog","blog",[151,155,159,163,167],{"title":152,"path":153,"stem":154},"How to Build a SaaS with Nuxt 4, better-auth, and Polar","\u002Fblog\u002Fbuild-saas-with-nuxt-4-better-auth-polar","blog\u002Fbuild-saas-with-nuxt-4-better-auth-polar",{"title":156,"path":157,"stem":158},"DIY vs Nuxt Starter Kit - The Real Cost of Auth and Payments","\u002Fblog\u002Fdiy-vs-nuxt-starter-kit-cost","blog\u002Fdiy-vs-nuxt-starter-kit-cost",{"title":160,"path":161,"stem":162},"Nuxt Boilerplate for Solo Founders - Ship Without Rebuilding Foundations","\u002Fblog\u002Fnuxt-boilerplate-for-solo-founders","blog\u002Fnuxt-boilerplate-for-solo-founders",{"title":164,"path":165,"stem":166},"Best Nuxt SaaS Boilerplate in 2026 - What Actually Matters","\u002Fblog\u002Fnuxt-saas-boilerplate-comparison","blog\u002Fnuxt-saas-boilerplate-comparison",{"title":168,"path":169,"stem":170},"Polar Checkout and Customer Portal in Nuxt with the better-auth Plugin","\u002Fblog\u002Fpolar-checkout-customer-portal-better-auth-nuxt","blog\u002Fpolar-checkout-customer-portal-better-auth-nuxt",false,{"title":173,"path":174,"stem":175,"children":176,"page":171},"Documentation","\u002Fdocs","docs",[177,185,189,192,195,198,201,204,207,210,213,216,219,222,226],{"title":5,"path":6,"stem":7,"children":178,"icon":31},[179,180,181,182,183,184],{"title":10,"path":6,"stem":7},{"title":12,"path":13,"stem":14},{"title":16,"path":17,"stem":18},{"title":20,"path":21,"stem":22},{"title":24,"path":25,"stem":26},{"title":28,"path":29,"stem":30},{"title":33,"path":34,"stem":35,"children":186,"icon":43},[187,188],{"title":38,"path":34,"stem":35},{"title":40,"path":41,"stem":42},{"title":45,"path":46,"stem":47,"children":190,"icon":51},[191],{"title":50,"path":46,"stem":47},{"title":53,"path":54,"stem":55,"children":193,"icon":59},[194],{"title":58,"path":54,"stem":55},{"title":61,"path":62,"stem":63,"children":196,"icon":66},[197],{"title":58,"path":62,"stem":63},{"title":68,"path":69,"stem":70,"children":199,"icon":74},[200],{"title":73,"path":69,"stem":70},{"title":76,"path":77,"stem":78,"children":202,"icon":82},[203],{"title":81,"path":77,"stem":78},{"title":84,"path":85,"stem":86,"children":205,"icon":89},[206],{"title":58,"path":85,"stem":86},{"title":91,"path":92,"stem":93,"children":208,"icon":96},[209],{"title":58,"path":92,"stem":93},{"title":98,"path":99,"stem":100,"children":211,"icon":103},[212],{"title":58,"path":99,"stem":100},{"title":105,"path":106,"stem":107,"children":214,"icon":111},[215],{"title":110,"path":106,"stem":107},{"title":113,"path":114,"stem":115,"children":217,"icon":118},[218],{"title":58,"path":114,"stem":115},{"title":120,"path":121,"stem":122,"children":220,"icon":126},[221],{"title":125,"path":121,"stem":122},{"title":128,"path":129,"stem":130,"children":223,"icon":138},[224,225],{"title":133,"path":129,"stem":130},{"title":135,"path":136,"stem":137},{"title":140,"path":141,"stem":142,"children":227},[228],{"title":140,"path":141,"stem":142},{"id":230,"title":168,"body":231,"date":2163,"description":2164,"draft":171,"extension":2165,"image":2166,"meta":2167,"navigation":459,"path":169,"seo":2168,"sitemap":2169,"stem":170,"tags":2170,"__hash__":2172},"blog\u002Fblog\u002Fpolar-checkout-customer-portal-better-auth-nuxt.md",{"type":232,"value":233,"toc":2151},"minimark",[234,244,259,283,288,291,294,297,300,331,334,370,383,387,390,680,683,716,719,866,870,881,1102,1105,1109,1112,1524,1534,1538,1541,1609,1612,1616,1619,1848,1858,1861,2042,2045,2054,2058,2061,2087,2090,2094,2105,2109,2122,2129,2147],[235,236,237,238,243],"p",{},"The first version of my ",[239,240,242],"a",{"href":241},"\u002F","Nuxt Starter Kit"," had its own Polar webhook handler. Polar sent every event to my server, and my code had to save it, handle duplicates and keep my database in sync with Polar. That's a lot of code for one question: \"Has this user paid?\"",[235,245,246,247,252,253,258],{},"Today, the kit answers this question with the ",[239,248,73],{"href":249,"rel":250},"https:\u002F\u002Fpolar.sh\u002F",[251],"nofollow"," plugin for ",[239,254,257],{"href":255,"rel":256},"https:\u002F\u002Fbetter-auth.com\u002F",[251],"better-auth",", and there is no webhook handler at all. In this article, I want to show you how I set up checkout, the customer portal and access checks in Nuxt 4 with this plugin.",[260,261,262],"note",{},[235,263,264,265,268,269,272,273,276,277,282],{},"I use Nuxt 4, ",[266,267,257],"code",{}," 1.7, ",[266,270,271],{},"@polar-sh\u002Fbetter-auth"," 2.1 and ",[266,274,275],{},"@polar-sh\u002Fsdk"," 1.0. You need a Polar account with at least one product. Create it in the ",[239,278,281],{"href":279,"rel":280},"https:\u002F\u002Fdocs.polar.sh\u002Fintegrate\u002Fsandbox",[251],"Polar sandbox"," first, so you can test without real money.",[284,285,287],"h2",{"id":286},"why-polar","Why Polar?",[235,289,290],{},"Global tax compliance is the main reason I picked Polar. Polar is a Merchant of Record, which means that legally, Polar sells your product to the customer. So Polar collects and pays sales tax and VAT in every country where you sell. As a solo founder, I sell to customers worldwide, and I don't want to handle the tax rules of each country myself.",[235,292,293],{},"The better-auth plugin connects Polar customers to better-auth users. You get checkout, the customer portal and the customer's subscription state as methods on the better-auth client.",[284,295,16],{"id":296},"setup",[235,298,299],{},"Let's start by installing the packages:",[301,302,307],"pre",{"className":303,"code":304,"language":305,"meta":306,"style":306},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pnpm add better-auth @polar-sh\u002Fbetter-auth @polar-sh\u002Fsdk\n","bash","",[266,308,309],{"__ignoreMap":306},[310,311,314,318,322,325,328],"span",{"class":312,"line":313},"line",1,[310,315,317],{"class":316},"sBMFI","pnpm",[310,319,321],{"class":320},"sfazB"," add",[310,323,324],{"class":320}," better-auth",[310,326,327],{"class":320}," @polar-sh\u002Fbetter-auth",[310,329,330],{"class":320}," @polar-sh\u002Fsdk\n",[235,332,333],{},"Next, we add three environment variables. You find the access token and the organization ID in your Polar settings:",[301,335,338],{"className":303,"code":336,"filename":337,"language":305,"meta":306,"style":306},"NUXT_PRIVATE_POLAR_ACCESS_TOKEN=\nNUXT_PRIVATE_POLAR_ORGANIZATION_ID=\nNUXT_PRIVATE_POLAR_SERVER=sandbox\n",".env",[266,339,340,350,358],{"__ignoreMap":306},[310,341,342,346],{"class":312,"line":313},[310,343,345],{"class":344},"sTEyZ","NUXT_PRIVATE_POLAR_ACCESS_TOKEN",[310,347,349],{"class":348},"sMK4o","=\n",[310,351,353,356],{"class":312,"line":352},2,[310,354,355],{"class":344},"NUXT_PRIVATE_POLAR_ORGANIZATION_ID",[310,357,349],{"class":348},[310,359,361,364,367],{"class":312,"line":360},3,[310,362,363],{"class":344},"NUXT_PRIVATE_POLAR_SERVER",[310,365,366],{"class":348},"=",[310,368,369],{"class":320},"sandbox\n",[235,371,372,374,375,378,379,382],{},[266,373,363],{}," is either ",[266,376,377],{},"sandbox"," or ",[266,380,381],{},"production",". Sandbox and production are separate Polar environments with separate tokens and products, so you need to switch all three values when you go live.",[284,384,386],{"id":385},"the-server-plugin","The Server Plugin",[235,388,389],{},"On the server, we create the Polar plugin in its own file:",[301,391,396],{"className":392,"code":393,"filename":394,"language":395,"meta":306,"style":306},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { checkout, polar, portal } from '@polar-sh\u002Fbetter-auth'\nimport { createPolarCore } from '@polar-sh\u002Fsdk\u002F2026-10'\n\nexport function setupPolar (accessToken: string, server: 'production' | 'sandbox') {\n  return polar({\n    client: createPolarCore({ accessToken, environment: server || undefined }),\n    createCustomerOnSignUp: true,\n    use: [\n      checkout({\n        authenticatedUsersOnly: true,\n        successUrl: '\u002Fdashboard',\n      }),\n      portal(),\n    ],\n  })\n}\n","server\u002Futils\u002Fpolar.ts","ts",[266,397,398,435,455,461,517,532,572,586,597,607,619,636,646,657,665,674],{"__ignoreMap":306},[310,399,400,404,407,410,413,416,418,421,424,427,430,432],{"class":312,"line":313},[310,401,403],{"class":402},"s7zQu","import",[310,405,406],{"class":348}," {",[310,408,409],{"class":344}," checkout",[310,411,412],{"class":348},",",[310,414,415],{"class":344}," polar",[310,417,412],{"class":348},[310,419,420],{"class":344}," portal",[310,422,423],{"class":348}," }",[310,425,426],{"class":402}," from",[310,428,429],{"class":348}," '",[310,431,271],{"class":320},[310,433,434],{"class":348},"'\n",[310,436,437,439,441,444,446,448,450,453],{"class":312,"line":352},[310,438,403],{"class":402},[310,440,406],{"class":348},[310,442,443],{"class":344}," createPolarCore",[310,445,423],{"class":348},[310,447,426],{"class":402},[310,449,429],{"class":348},[310,451,452],{"class":320},"@polar-sh\u002Fsdk\u002F2026-10",[310,454,434],{"class":348},[310,456,457],{"class":312,"line":360},[310,458,460],{"emptyLinePlaceholder":459},true,"\n",[310,462,464,467,471,475,478,482,485,488,490,493,495,497,499,502,505,507,509,511,514],{"class":312,"line":463},4,[310,465,466],{"class":402},"export",[310,468,470],{"class":469},"spNyl"," function",[310,472,474],{"class":473},"s2Zo4"," setupPolar",[310,476,477],{"class":348}," (",[310,479,481],{"class":480},"sHdIc","accessToken",[310,483,484],{"class":348},":",[310,486,487],{"class":316}," string",[310,489,412],{"class":348},[310,491,492],{"class":480}," server",[310,494,484],{"class":348},[310,496,429],{"class":348},[310,498,381],{"class":320},[310,500,501],{"class":348},"'",[310,503,504],{"class":348}," |",[310,506,429],{"class":348},[310,508,377],{"class":320},[310,510,501],{"class":348},[310,512,513],{"class":348},")",[310,515,516],{"class":348}," {\n",[310,518,520,523,525,529],{"class":312,"line":519},5,[310,521,522],{"class":402},"  return",[310,524,415],{"class":473},[310,526,528],{"class":527},"swJcz","(",[310,530,531],{"class":348},"{\n",[310,533,535,538,540,542,544,547,550,552,555,557,559,562,565,567,569],{"class":312,"line":534},6,[310,536,537],{"class":527},"    client",[310,539,484],{"class":348},[310,541,443],{"class":473},[310,543,528],{"class":527},[310,545,546],{"class":348},"{",[310,548,549],{"class":344}," accessToken",[310,551,412],{"class":348},[310,553,554],{"class":527}," environment",[310,556,484],{"class":348},[310,558,492],{"class":344},[310,560,561],{"class":348}," ||",[310,563,564],{"class":348}," undefined",[310,566,423],{"class":348},[310,568,513],{"class":527},[310,570,571],{"class":348},",\n",[310,573,575,578,580,584],{"class":312,"line":574},7,[310,576,577],{"class":527},"    createCustomerOnSignUp",[310,579,484],{"class":348},[310,581,583],{"class":582},"sfNiH"," true",[310,585,571],{"class":348},[310,587,589,592,594],{"class":312,"line":588},8,[310,590,591],{"class":527},"    use",[310,593,484],{"class":348},[310,595,596],{"class":527}," [\n",[310,598,600,603,605],{"class":312,"line":599},9,[310,601,602],{"class":473},"      checkout",[310,604,528],{"class":527},[310,606,531],{"class":348},[310,608,610,613,615,617],{"class":312,"line":609},10,[310,611,612],{"class":527},"        authenticatedUsersOnly",[310,614,484],{"class":348},[310,616,583],{"class":582},[310,618,571],{"class":348},[310,620,622,625,627,629,632,634],{"class":312,"line":621},11,[310,623,624],{"class":527},"        successUrl",[310,626,484],{"class":348},[310,628,429],{"class":348},[310,630,631],{"class":320},"\u002Fdashboard",[310,633,501],{"class":348},[310,635,571],{"class":348},[310,637,639,642,644],{"class":312,"line":638},12,[310,640,641],{"class":348},"      }",[310,643,513],{"class":527},[310,645,571],{"class":348},[310,647,649,652,655],{"class":312,"line":648},13,[310,650,651],{"class":473},"      portal",[310,653,654],{"class":527},"()",[310,656,571],{"class":348},[310,658,660,663],{"class":312,"line":659},14,[310,661,662],{"class":527},"    ]",[310,664,571],{"class":348},[310,666,668,671],{"class":312,"line":667},15,[310,669,670],{"class":348},"  }",[310,672,673],{"class":527},")\n",[310,675,677],{"class":312,"line":676},16,[310,678,679],{"class":348},"}\n",[235,681,682],{},"Let's analyze the above code:",[684,685,686,697,710],"ul",{},[687,688,689,692,693,696],"li",{},[266,690,691],{},"createCustomerOnSignUp"," creates a Polar customer for every new user. The plugin stores the better-auth user ID as ",[266,694,695],{},"external_id"," on the customer. That's how Polar knows which user paid, and I never have to match payments by email.",[687,698,699,702,703,706,707,709],{},[266,700,701],{},"checkout()"," adds a checkout endpoint. With ",[266,704,705],{},"authenticatedUsersOnly",", only signed-in users can buy, so every order belongs to a user account. After the payment, Polar redirects to ",[266,708,631],{},".",[687,711,712,715],{},[266,713,714],{},"portal()"," adds the customer portal and the endpoints to read the customer's state and orders.",[235,717,718],{},"Then we add the plugin to the better-auth config:",[301,720,723],{"className":392,"code":721,"filename":722,"language":395,"meta":306,"style":306},"export function createBetterAuth () {\n  const runtimeConfig = useRuntimeConfig()\n\n  return betterAuth({\n    \u002F\u002F database, emailAndPassword, socialProviders...\n    plugins: [\n      setupPolar(\n        runtimeConfig.private.polarAccessToken,\n        runtimeConfig.private.polarServer as 'production' | 'sandbox',\n      ),\n    ],\n  })\n}\n","server\u002Futils\u002Fauth.ts",[266,724,725,739,756,760,771,777,786,794,811,843,850,856,862],{"__ignoreMap":306},[310,726,727,729,731,734,737],{"class":312,"line":313},[310,728,466],{"class":402},[310,730,470],{"class":469},[310,732,733],{"class":473}," createBetterAuth",[310,735,736],{"class":348}," ()",[310,738,516],{"class":348},[310,740,741,744,747,750,753],{"class":312,"line":352},[310,742,743],{"class":469},"  const",[310,745,746],{"class":344}," runtimeConfig",[310,748,749],{"class":348}," =",[310,751,752],{"class":473}," useRuntimeConfig",[310,754,755],{"class":527},"()\n",[310,757,758],{"class":312,"line":360},[310,759,460],{"emptyLinePlaceholder":459},[310,761,762,764,767,769],{"class":312,"line":463},[310,763,522],{"class":402},[310,765,766],{"class":473}," betterAuth",[310,768,528],{"class":527},[310,770,531],{"class":348},[310,772,773],{"class":312,"line":519},[310,774,776],{"class":775},"sHwdD","    \u002F\u002F database, emailAndPassword, socialProviders...\n",[310,778,779,782,784],{"class":312,"line":534},[310,780,781],{"class":527},"    plugins",[310,783,484],{"class":348},[310,785,596],{"class":527},[310,787,788,791],{"class":312,"line":574},[310,789,790],{"class":473},"      setupPolar",[310,792,793],{"class":527},"(\n",[310,795,796,799,801,804,806,809],{"class":312,"line":588},[310,797,798],{"class":344},"        runtimeConfig",[310,800,709],{"class":348},[310,802,803],{"class":344},"private",[310,805,709],{"class":348},[310,807,808],{"class":344},"polarAccessToken",[310,810,571],{"class":348},[310,812,813,815,817,819,821,824,827,829,831,833,835,837,839,841],{"class":312,"line":599},[310,814,798],{"class":344},[310,816,709],{"class":348},[310,818,803],{"class":344},[310,820,709],{"class":348},[310,822,823],{"class":344},"polarServer",[310,825,826],{"class":402}," as",[310,828,429],{"class":348},[310,830,381],{"class":320},[310,832,501],{"class":348},[310,834,504],{"class":348},[310,836,429],{"class":348},[310,838,377],{"class":320},[310,840,501],{"class":348},[310,842,571],{"class":348},[310,844,845,848],{"class":312,"line":609},[310,846,847],{"class":527},"      )",[310,849,571],{"class":348},[310,851,852,854],{"class":312,"line":621},[310,853,662],{"class":527},[310,855,571],{"class":348},[310,857,858,860],{"class":312,"line":638},[310,859,670],{"class":348},[310,861,673],{"class":527},[310,863,864],{"class":312,"line":648},[310,865,679],{"class":348},[284,867,869],{"id":868},"the-client-plugin","The Client Plugin",[235,871,872,873,876,877,880],{},"On the client, we add ",[266,874,875],{},"polarClient()"," to the better-auth client. In the kit, the client lives in a ",[266,878,879],{},"useAuth()"," composable:",[301,882,885],{"className":392,"code":883,"filename":884,"language":395,"meta":306,"style":306},"import { polarClient } from '@polar-sh\u002Fbetter-auth\u002Fclient'\nimport { createAuthClient } from 'better-auth\u002Fvue'\n\nexport function useAuth () {\n  const url = useRequestURL()\n  const headers = import.meta.server\n    ? useRequestHeaders()\n    : undefined\n\n  const client = createAuthClient({\n    baseURL: url.origin,\n    fetchOptions: { headers },\n    plugins: [\n      polarClient()\n    ],\n  })\n\n  \u002F\u002F session handling...\n  return { client }\n}\n","app\u002Fcomposables\u002FuseAuth.ts",[266,886,887,907,927,931,944,958,980,990,998,1002,1017,1033,1047,1055,1062,1068,1074,1079,1085,1097],{"__ignoreMap":306},[310,888,889,891,893,896,898,900,902,905],{"class":312,"line":313},[310,890,403],{"class":402},[310,892,406],{"class":348},[310,894,895],{"class":344}," polarClient",[310,897,423],{"class":348},[310,899,426],{"class":402},[310,901,429],{"class":348},[310,903,904],{"class":320},"@polar-sh\u002Fbetter-auth\u002Fclient",[310,906,434],{"class":348},[310,908,909,911,913,916,918,920,922,925],{"class":312,"line":352},[310,910,403],{"class":402},[310,912,406],{"class":348},[310,914,915],{"class":344}," createAuthClient",[310,917,423],{"class":348},[310,919,426],{"class":402},[310,921,429],{"class":348},[310,923,924],{"class":320},"better-auth\u002Fvue",[310,926,434],{"class":348},[310,928,929],{"class":312,"line":360},[310,930,460],{"emptyLinePlaceholder":459},[310,932,933,935,937,940,942],{"class":312,"line":463},[310,934,466],{"class":402},[310,936,470],{"class":469},[310,938,939],{"class":473}," useAuth",[310,941,736],{"class":348},[310,943,516],{"class":348},[310,945,946,948,951,953,956],{"class":312,"line":519},[310,947,743],{"class":469},[310,949,950],{"class":344}," url",[310,952,749],{"class":348},[310,954,955],{"class":473}," useRequestURL",[310,957,755],{"class":527},[310,959,960,962,965,967,970,972,975,977],{"class":312,"line":534},[310,961,743],{"class":469},[310,963,964],{"class":344}," headers",[310,966,749],{"class":348},[310,968,969],{"class":402}," import",[310,971,709],{"class":348},[310,973,974],{"class":344},"meta",[310,976,709],{"class":348},[310,978,979],{"class":344},"server\n",[310,981,982,985,988],{"class":312,"line":574},[310,983,984],{"class":348},"    ?",[310,986,987],{"class":473}," useRequestHeaders",[310,989,755],{"class":527},[310,991,992,995],{"class":312,"line":588},[310,993,994],{"class":348},"    :",[310,996,997],{"class":348}," undefined\n",[310,999,1000],{"class":312,"line":599},[310,1001,460],{"emptyLinePlaceholder":459},[310,1003,1004,1006,1009,1011,1013,1015],{"class":312,"line":609},[310,1005,743],{"class":469},[310,1007,1008],{"class":344}," client",[310,1010,749],{"class":348},[310,1012,915],{"class":473},[310,1014,528],{"class":527},[310,1016,531],{"class":348},[310,1018,1019,1022,1024,1026,1028,1031],{"class":312,"line":621},[310,1020,1021],{"class":527},"    baseURL",[310,1023,484],{"class":348},[310,1025,950],{"class":344},[310,1027,709],{"class":348},[310,1029,1030],{"class":344},"origin",[310,1032,571],{"class":348},[310,1034,1035,1038,1040,1042,1044],{"class":312,"line":638},[310,1036,1037],{"class":527},"    fetchOptions",[310,1039,484],{"class":348},[310,1041,406],{"class":348},[310,1043,964],{"class":344},[310,1045,1046],{"class":348}," },\n",[310,1048,1049,1051,1053],{"class":312,"line":648},[310,1050,781],{"class":527},[310,1052,484],{"class":348},[310,1054,596],{"class":527},[310,1056,1057,1060],{"class":312,"line":659},[310,1058,1059],{"class":473},"      polarClient",[310,1061,755],{"class":527},[310,1063,1064,1066],{"class":312,"line":667},[310,1065,662],{"class":527},[310,1067,571],{"class":348},[310,1069,1070,1072],{"class":312,"line":676},[310,1071,670],{"class":348},[310,1073,673],{"class":527},[310,1075,1077],{"class":312,"line":1076},17,[310,1078,460],{"emptyLinePlaceholder":459},[310,1080,1082],{"class":312,"line":1081},18,[310,1083,1084],{"class":775},"  \u002F\u002F session handling...\n",[310,1086,1088,1090,1092,1094],{"class":312,"line":1087},19,[310,1089,522],{"class":402},[310,1091,406],{"class":348},[310,1093,1008],{"class":344},[310,1095,1096],{"class":348}," }\n",[310,1098,1100],{"class":312,"line":1099},20,[310,1101,679],{"class":348},[235,1103,1104],{},"On the server, we pass the request headers to the client. Without them, a server-rendered page would load without the session cookie, and the user would look signed out.",[284,1106,1108],{"id":1107},"listing-the-products","Listing the Products",[235,1110,1111],{},"To show prices on a pricing page, we need the products from Polar. The better-auth plugin doesn't load products, so I use the Polar SDK directly in a server route:",[301,1113,1116],{"className":392,"code":1114,"filename":1115,"language":395,"meta":306,"style":306},"import { createPolar } from '@polar-sh\u002Fsdk\u002F2026-10'\n\nexport default defineEventHandler(async (event) => {\n  const { private: { polarAccessToken, polarOrganizationId, polarServer } } = useRuntimeConfig(event)\n\n  const polar = createPolar({\n    accessToken: polarAccessToken,\n    environment: polarServer as 'production' | 'sandbox',\n  })\n\n  const result = await polar.products.list({\n    is_archived: false,\n    organization_id: polarOrganizationId || undefined,\n  })\n\n  return result.items.map(product => ({\n    id: product.id,\n    name: product.name,\n    price: product.prices[0]?.amount_type === 'fixed'\n      ? product.prices[0].price_amount\n      : 0,\n    type: product.is_recurring ? 'recurring' : 'one-time',\n  }))\n})\n","server\u002Fapi\u002Fpayment\u002Fproducts.get.ts",[266,1117,1118,1137,1141,1168,1208,1212,1226,1237,1264,1270,1274,1302,1314,1328,1334,1338,1365,1382,1398,1438,1460,1471,1508,1516],{"__ignoreMap":306},[310,1119,1120,1122,1124,1127,1129,1131,1133,1135],{"class":312,"line":313},[310,1121,403],{"class":402},[310,1123,406],{"class":348},[310,1125,1126],{"class":344}," createPolar",[310,1128,423],{"class":348},[310,1130,426],{"class":402},[310,1132,429],{"class":348},[310,1134,452],{"class":320},[310,1136,434],{"class":348},[310,1138,1139],{"class":312,"line":352},[310,1140,460],{"emptyLinePlaceholder":459},[310,1142,1143,1145,1148,1151,1153,1156,1158,1161,1163,1166],{"class":312,"line":360},[310,1144,466],{"class":402},[310,1146,1147],{"class":402}," default",[310,1149,1150],{"class":473}," defineEventHandler",[310,1152,528],{"class":344},[310,1154,1155],{"class":469},"async",[310,1157,477],{"class":348},[310,1159,1160],{"class":480},"event",[310,1162,513],{"class":348},[310,1164,1165],{"class":469}," =>",[310,1167,516],{"class":348},[310,1169,1170,1172,1174,1177,1179,1181,1184,1186,1189,1191,1194,1196,1198,1200,1202,1204,1206],{"class":312,"line":463},[310,1171,743],{"class":469},[310,1173,406],{"class":348},[310,1175,1176],{"class":527}," private",[310,1178,484],{"class":348},[310,1180,406],{"class":348},[310,1182,1183],{"class":344}," polarAccessToken",[310,1185,412],{"class":348},[310,1187,1188],{"class":344}," polarOrganizationId",[310,1190,412],{"class":348},[310,1192,1193],{"class":344}," polarServer",[310,1195,423],{"class":348},[310,1197,423],{"class":348},[310,1199,749],{"class":348},[310,1201,752],{"class":473},[310,1203,528],{"class":527},[310,1205,1160],{"class":344},[310,1207,673],{"class":527},[310,1209,1210],{"class":312,"line":519},[310,1211,460],{"emptyLinePlaceholder":459},[310,1213,1214,1216,1218,1220,1222,1224],{"class":312,"line":534},[310,1215,743],{"class":469},[310,1217,415],{"class":344},[310,1219,749],{"class":348},[310,1221,1126],{"class":473},[310,1223,528],{"class":527},[310,1225,531],{"class":348},[310,1227,1228,1231,1233,1235],{"class":312,"line":574},[310,1229,1230],{"class":527},"    accessToken",[310,1232,484],{"class":348},[310,1234,1183],{"class":344},[310,1236,571],{"class":348},[310,1238,1239,1242,1244,1246,1248,1250,1252,1254,1256,1258,1260,1262],{"class":312,"line":588},[310,1240,1241],{"class":527},"    environment",[310,1243,484],{"class":348},[310,1245,1193],{"class":344},[310,1247,826],{"class":402},[310,1249,429],{"class":348},[310,1251,381],{"class":320},[310,1253,501],{"class":348},[310,1255,504],{"class":348},[310,1257,429],{"class":348},[310,1259,377],{"class":320},[310,1261,501],{"class":348},[310,1263,571],{"class":348},[310,1265,1266,1268],{"class":312,"line":599},[310,1267,670],{"class":348},[310,1269,673],{"class":527},[310,1271,1272],{"class":312,"line":609},[310,1273,460],{"emptyLinePlaceholder":459},[310,1275,1276,1278,1281,1283,1286,1288,1290,1293,1295,1298,1300],{"class":312,"line":621},[310,1277,743],{"class":469},[310,1279,1280],{"class":344}," result",[310,1282,749],{"class":348},[310,1284,1285],{"class":402}," await",[310,1287,415],{"class":344},[310,1289,709],{"class":348},[310,1291,1292],{"class":344},"products",[310,1294,709],{"class":348},[310,1296,1297],{"class":473},"list",[310,1299,528],{"class":527},[310,1301,531],{"class":348},[310,1303,1304,1307,1309,1312],{"class":312,"line":638},[310,1305,1306],{"class":527},"    is_archived",[310,1308,484],{"class":348},[310,1310,1311],{"class":582}," false",[310,1313,571],{"class":348},[310,1315,1316,1319,1321,1323,1325],{"class":312,"line":648},[310,1317,1318],{"class":527},"    organization_id",[310,1320,484],{"class":348},[310,1322,1188],{"class":344},[310,1324,561],{"class":348},[310,1326,1327],{"class":348}," undefined,\n",[310,1329,1330,1332],{"class":312,"line":659},[310,1331,670],{"class":348},[310,1333,673],{"class":527},[310,1335,1336],{"class":312,"line":667},[310,1337,460],{"emptyLinePlaceholder":459},[310,1339,1340,1342,1344,1346,1349,1351,1354,1356,1359,1361,1363],{"class":312,"line":676},[310,1341,522],{"class":402},[310,1343,1280],{"class":344},[310,1345,709],{"class":348},[310,1347,1348],{"class":344},"items",[310,1350,709],{"class":348},[310,1352,1353],{"class":473},"map",[310,1355,528],{"class":527},[310,1357,1358],{"class":480},"product",[310,1360,1165],{"class":469},[310,1362,477],{"class":527},[310,1364,531],{"class":348},[310,1366,1367,1370,1372,1375,1377,1380],{"class":312,"line":1076},[310,1368,1369],{"class":527},"    id",[310,1371,484],{"class":348},[310,1373,1374],{"class":344}," product",[310,1376,709],{"class":348},[310,1378,1379],{"class":344},"id",[310,1381,571],{"class":348},[310,1383,1384,1387,1389,1391,1393,1396],{"class":312,"line":1081},[310,1385,1386],{"class":527},"    name",[310,1388,484],{"class":348},[310,1390,1374],{"class":344},[310,1392,709],{"class":348},[310,1394,1395],{"class":344},"name",[310,1397,571],{"class":348},[310,1399,1400,1403,1405,1407,1409,1412,1415,1419,1422,1425,1428,1431,1433,1436],{"class":312,"line":1087},[310,1401,1402],{"class":527},"    price",[310,1404,484],{"class":348},[310,1406,1374],{"class":344},[310,1408,709],{"class":348},[310,1410,1411],{"class":344},"prices",[310,1413,1414],{"class":527},"[",[310,1416,1418],{"class":1417},"sbssI","0",[310,1420,1421],{"class":527},"]",[310,1423,1424],{"class":348},"?.",[310,1426,1427],{"class":344},"amount_type",[310,1429,1430],{"class":348}," ===",[310,1432,429],{"class":348},[310,1434,1435],{"class":320},"fixed",[310,1437,434],{"class":348},[310,1439,1440,1443,1445,1447,1449,1451,1453,1455,1457],{"class":312,"line":1099},[310,1441,1442],{"class":348},"      ?",[310,1444,1374],{"class":344},[310,1446,709],{"class":348},[310,1448,1411],{"class":344},[310,1450,1414],{"class":527},[310,1452,1418],{"class":1417},[310,1454,1421],{"class":527},[310,1456,709],{"class":348},[310,1458,1459],{"class":344},"price_amount\n",[310,1461,1463,1466,1469],{"class":312,"line":1462},21,[310,1464,1465],{"class":348},"      :",[310,1467,1468],{"class":1417}," 0",[310,1470,571],{"class":348},[310,1472,1474,1477,1479,1481,1483,1486,1489,1491,1494,1496,1499,1501,1504,1506],{"class":312,"line":1473},22,[310,1475,1476],{"class":527},"    type",[310,1478,484],{"class":348},[310,1480,1374],{"class":344},[310,1482,709],{"class":348},[310,1484,1485],{"class":344},"is_recurring",[310,1487,1488],{"class":348}," ?",[310,1490,429],{"class":348},[310,1492,1493],{"class":320},"recurring",[310,1495,501],{"class":348},[310,1497,1498],{"class":348}," :",[310,1500,429],{"class":348},[310,1502,1503],{"class":320},"one-time",[310,1505,501],{"class":348},[310,1507,571],{"class":348},[310,1509,1511,1513],{"class":312,"line":1510},23,[310,1512,670],{"class":348},[310,1514,1515],{"class":527},"))\n",[310,1517,1519,1522],{"class":312,"line":1518},24,[310,1520,1521],{"class":348},"}",[310,1523,673],{"class":344},[235,1525,1526,1529,1530,1533],{},[266,1527,1528],{},"is_archived: false"," hides products you archived in Polar. Polar returns prices in cents, so a price of ",[266,1531,1532],{},"4900"," means $49.00.",[284,1535,1537],{"id":1536},"starting-the-checkout","Starting the Checkout",[235,1539,1540],{},"Starting a checkout is one method call:",[301,1542,1544],{"className":392,"code":1543,"language":395,"meta":306,"style":306},"const auth = useAuth()\n\nawait auth.client.checkout({\n  products: [product.id],\n})\n",[266,1545,1546,1560,1564,1586,1603],{"__ignoreMap":306},[310,1547,1548,1551,1554,1556,1558],{"class":312,"line":313},[310,1549,1550],{"class":469},"const",[310,1552,1553],{"class":344}," auth ",[310,1555,366],{"class":348},[310,1557,939],{"class":473},[310,1559,755],{"class":344},[310,1561,1562],{"class":312,"line":352},[310,1563,460],{"emptyLinePlaceholder":459},[310,1565,1566,1569,1572,1574,1577,1579,1582,1584],{"class":312,"line":360},[310,1567,1568],{"class":402},"await",[310,1570,1571],{"class":344}," auth",[310,1573,709],{"class":348},[310,1575,1576],{"class":344},"client",[310,1578,709],{"class":348},[310,1580,1581],{"class":473},"checkout",[310,1583,528],{"class":344},[310,1585,531],{"class":348},[310,1587,1588,1591,1593,1596,1598,1601],{"class":312,"line":463},[310,1589,1590],{"class":527},"  products",[310,1592,484],{"class":348},[310,1594,1595],{"class":344}," [product",[310,1597,709],{"class":348},[310,1599,1600],{"class":344},"id]",[310,1602,571],{"class":348},[310,1604,1605,1607],{"class":312,"line":519},[310,1606,1521],{"class":348},[310,1608,673],{"class":344},[235,1610,1611],{},"The plugin creates a checkout session for the signed-in user and redirects to Polar's checkout page. The kit uses the same call for the monthly plan, the yearly plan and the lifetime deal. Only the product ID changes.",[284,1613,1615],{"id":1614},"checking-access-without-webhooks","Checking Access Without Webhooks",[235,1617,1618],{},"Now to the part that replaced my webhook handler. After sign-in, the kit asks Polar for the customer's current state:",[301,1620,1622],{"className":392,"code":1621,"filename":884,"language":395,"meta":306,"style":306},"const polarState = useState\u003Cmodels.CustomerState | null>('auth:polarState', () => null)\n\nasync function fetchSession () {\n  const { data } = await client.getSession()\n  \u002F\u002F set session and user...\n\n  if (data?.user) {\n    const { data: customerState } = await client.customer.state()\n    polarState.value = customerState\n  }\n}\n\nconst activeSubscription = computed(() => polarState.value?.active_subscriptions[0] ?? null)\n",[266,1623,1624,1674,1678,1691,1715,1720,1724,1744,1778,1793,1798,1802,1806],{"__ignoreMap":306},[310,1625,1626,1628,1631,1633,1636,1639,1642,1644,1647,1649,1652,1655,1657,1659,1662,1664,1666,1668,1670,1672],{"class":312,"line":313},[310,1627,1550],{"class":469},[310,1629,1630],{"class":344}," polarState ",[310,1632,366],{"class":348},[310,1634,1635],{"class":473}," useState",[310,1637,1638],{"class":348},"\u003C",[310,1640,1641],{"class":316},"models",[310,1643,709],{"class":348},[310,1645,1646],{"class":316},"CustomerState",[310,1648,504],{"class":348},[310,1650,1651],{"class":316}," null",[310,1653,1654],{"class":348},">",[310,1656,528],{"class":344},[310,1658,501],{"class":348},[310,1660,1661],{"class":320},"auth:polarState",[310,1663,501],{"class":348},[310,1665,412],{"class":348},[310,1667,736],{"class":348},[310,1669,1165],{"class":469},[310,1671,1651],{"class":348},[310,1673,673],{"class":344},[310,1675,1676],{"class":312,"line":352},[310,1677,460],{"emptyLinePlaceholder":459},[310,1679,1680,1682,1684,1687,1689],{"class":312,"line":360},[310,1681,1155],{"class":469},[310,1683,470],{"class":469},[310,1685,1686],{"class":473}," fetchSession",[310,1688,736],{"class":348},[310,1690,516],{"class":348},[310,1692,1693,1695,1697,1700,1702,1704,1706,1708,1710,1713],{"class":312,"line":463},[310,1694,743],{"class":469},[310,1696,406],{"class":348},[310,1698,1699],{"class":344}," data",[310,1701,423],{"class":348},[310,1703,749],{"class":348},[310,1705,1285],{"class":402},[310,1707,1008],{"class":344},[310,1709,709],{"class":348},[310,1711,1712],{"class":473},"getSession",[310,1714,755],{"class":527},[310,1716,1717],{"class":312,"line":519},[310,1718,1719],{"class":775},"  \u002F\u002F set session and user...\n",[310,1721,1722],{"class":312,"line":534},[310,1723,460],{"emptyLinePlaceholder":459},[310,1725,1726,1729,1731,1734,1736,1739,1742],{"class":312,"line":574},[310,1727,1728],{"class":402},"  if",[310,1730,477],{"class":527},[310,1732,1733],{"class":344},"data",[310,1735,1424],{"class":348},[310,1737,1738],{"class":344},"user",[310,1740,1741],{"class":527},") ",[310,1743,531],{"class":348},[310,1745,1746,1749,1751,1753,1755,1758,1760,1762,1764,1766,1768,1771,1773,1776],{"class":312,"line":588},[310,1747,1748],{"class":469},"    const",[310,1750,406],{"class":348},[310,1752,1699],{"class":527},[310,1754,484],{"class":348},[310,1756,1757],{"class":344}," customerState",[310,1759,423],{"class":348},[310,1761,749],{"class":348},[310,1763,1285],{"class":402},[310,1765,1008],{"class":344},[310,1767,709],{"class":348},[310,1769,1770],{"class":344},"customer",[310,1772,709],{"class":348},[310,1774,1775],{"class":473},"state",[310,1777,755],{"class":527},[310,1779,1780,1783,1785,1788,1790],{"class":312,"line":599},[310,1781,1782],{"class":344},"    polarState",[310,1784,709],{"class":348},[310,1786,1787],{"class":344},"value",[310,1789,749],{"class":348},[310,1791,1792],{"class":344}," customerState\n",[310,1794,1795],{"class":312,"line":609},[310,1796,1797],{"class":348},"  }\n",[310,1799,1800],{"class":312,"line":621},[310,1801,679],{"class":348},[310,1803,1804],{"class":312,"line":638},[310,1805,460],{"emptyLinePlaceholder":459},[310,1807,1808,1810,1813,1815,1818,1820,1822,1824,1827,1829,1831,1833,1836,1838,1841,1844,1846],{"class":312,"line":648},[310,1809,1550],{"class":469},[310,1811,1812],{"class":344}," activeSubscription ",[310,1814,366],{"class":348},[310,1816,1817],{"class":473}," computed",[310,1819,528],{"class":344},[310,1821,654],{"class":348},[310,1823,1165],{"class":469},[310,1825,1826],{"class":344}," polarState",[310,1828,709],{"class":348},[310,1830,1787],{"class":344},[310,1832,1424],{"class":348},[310,1834,1835],{"class":344},"active_subscriptions[",[310,1837,1418],{"class":1417},[310,1839,1840],{"class":344},"] ",[310,1842,1843],{"class":348},"??",[310,1845,1651],{"class":348},[310,1847,673],{"class":344},[235,1849,1850,1853,1854,1857],{},[266,1851,1852],{},"customer.state()"," returns the customer with all active subscriptions. If ",[266,1855,1856],{},"active_subscriptions"," isn't empty, the user has a paid plan.",[235,1859,1860],{},"A lifetime deal is a one-time order, not a subscription, so it never shows up there. For this case, the kit loads the user's one-time orders:",[301,1862,1865],{"className":392,"code":1863,"filename":1864,"language":395,"meta":306,"style":306},"const res = await auth.client.customer.orders.list({\n  query: {\n    limit: 10,\n    page: 1,\n    productBillingType: 'one_time',\n  },\n})\n\nconst order = res.data?.items[0]\nconst hasLifetimeDeal = order?.product_id === lifetimeDealProduct.value?.id && order?.status === 'paid'\n","app\u002Fcomposables\u002FuseBilling.ts",[266,1866,1867,1901,1910,1922,1934,1950,1955,1961,1965,1991],{"__ignoreMap":306},[310,1868,1869,1871,1874,1876,1878,1880,1882,1884,1886,1888,1890,1893,1895,1897,1899],{"class":312,"line":313},[310,1870,1550],{"class":469},[310,1872,1873],{"class":344}," res ",[310,1875,366],{"class":348},[310,1877,1285],{"class":402},[310,1879,1571],{"class":344},[310,1881,709],{"class":348},[310,1883,1576],{"class":344},[310,1885,709],{"class":348},[310,1887,1770],{"class":344},[310,1889,709],{"class":348},[310,1891,1892],{"class":344},"orders",[310,1894,709],{"class":348},[310,1896,1297],{"class":473},[310,1898,528],{"class":344},[310,1900,531],{"class":348},[310,1902,1903,1906,1908],{"class":312,"line":352},[310,1904,1905],{"class":527},"  query",[310,1907,484],{"class":348},[310,1909,516],{"class":348},[310,1911,1912,1915,1917,1920],{"class":312,"line":360},[310,1913,1914],{"class":527},"    limit",[310,1916,484],{"class":348},[310,1918,1919],{"class":1417}," 10",[310,1921,571],{"class":348},[310,1923,1924,1927,1929,1932],{"class":312,"line":463},[310,1925,1926],{"class":527},"    page",[310,1928,484],{"class":348},[310,1930,1931],{"class":1417}," 1",[310,1933,571],{"class":348},[310,1935,1936,1939,1941,1943,1946,1948],{"class":312,"line":519},[310,1937,1938],{"class":527},"    productBillingType",[310,1940,484],{"class":348},[310,1942,429],{"class":348},[310,1944,1945],{"class":320},"one_time",[310,1947,501],{"class":348},[310,1949,571],{"class":348},[310,1951,1952],{"class":312,"line":534},[310,1953,1954],{"class":348},"  },\n",[310,1956,1957,1959],{"class":312,"line":574},[310,1958,1521],{"class":348},[310,1960,673],{"class":344},[310,1962,1963],{"class":312,"line":588},[310,1964,460],{"emptyLinePlaceholder":459},[310,1966,1967,1969,1972,1974,1977,1979,1981,1983,1986,1988],{"class":312,"line":599},[310,1968,1550],{"class":469},[310,1970,1971],{"class":344}," order ",[310,1973,366],{"class":348},[310,1975,1976],{"class":344}," res",[310,1978,709],{"class":348},[310,1980,1733],{"class":344},[310,1982,1424],{"class":348},[310,1984,1985],{"class":344},"items[",[310,1987,1418],{"class":1417},[310,1989,1990],{"class":344},"]\n",[310,1992,1993,1995,1998,2000,2003,2005,2008,2011,2014,2016,2018,2020,2023,2026,2028,2030,2033,2035,2037,2040],{"class":312,"line":609},[310,1994,1550],{"class":469},[310,1996,1997],{"class":344}," hasLifetimeDeal ",[310,1999,366],{"class":348},[310,2001,2002],{"class":344}," order",[310,2004,1424],{"class":348},[310,2006,2007],{"class":344},"product_id ",[310,2009,2010],{"class":348},"===",[310,2012,2013],{"class":344}," lifetimeDealProduct",[310,2015,709],{"class":348},[310,2017,1787],{"class":344},[310,2019,1424],{"class":348},[310,2021,2022],{"class":344},"id ",[310,2024,2025],{"class":348},"&&",[310,2027,2002],{"class":344},[310,2029,1424],{"class":348},[310,2031,2032],{"class":344},"status ",[310,2034,2010],{"class":348},[310,2036,429],{"class":348},[310,2038,2039],{"class":320},"paid",[310,2041,434],{"class":348},[235,2043,2044],{},"My app doesn't store any payment data. Polar is the only source of truth, so my database can't get out of sync with it.",[2046,2047,2048],"warning",{},[235,2049,2050,2051,2053],{},"Checks in a composable only control what the UI shows. If a server route returns paid content, check the customer state on the server too, for example with the Polar SDK and the user's ID as ",[266,2052,695],{},". Users can call your API without your UI.",[284,2055,2057],{"id":2056},"the-customer-portal","The Customer Portal",[235,2059,2060],{},"Users need to cancel, change their plan, update their card and download invoices. I don't build any of this. Polar's customer portal does it, and opening it is one line:",[301,2062,2064],{"className":392,"code":2063,"language":395,"meta":306,"style":306},"await auth.client.customer.portal()\n",[266,2065,2066],{"__ignoreMap":306},[310,2067,2068,2070,2072,2074,2076,2078,2080,2082,2085],{"class":312,"line":313},[310,2069,1568],{"class":402},[310,2071,1571],{"class":344},[310,2073,709],{"class":348},[310,2075,1576],{"class":344},[310,2077,709],{"class":348},[310,2079,1770],{"class":344},[310,2081,709],{"class":348},[310,2083,2084],{"class":473},"portal",[310,2086,755],{"class":344},[235,2088,2089],{},"The plugin creates a portal session for the signed-in user and redirects to Polar. In the kit, the billing card in the dashboard and the \"Downgrade\" button on the free plan both call this method.",[284,2091,2093],{"id":2092},"testing-in-the-sandbox","Testing in the Sandbox",[235,2095,2096,2097,2100,2101,2104],{},"With ",[266,2098,2099],{},"NUXT_PRIVATE_POLAR_SERVER=sandbox",", you can buy with Stripe's test card ",[266,2102,2103],{},"4242 4242 4242 4242",", any future expiry date and any CVC. Try it yourself: sign up, buy a product, and check that the dashboard shows the paid plan after the redirect. Then open the customer portal and cancel the subscription.",[284,2106,2108],{"id":2107},"conclusion","Conclusion",[235,2110,2111,2112,2114,2115,2117,2118,2121],{},"I'm very happy that I dropped my webhook handler. The whole payment integration is now a few plugin options and three client calls: ",[266,2113,701],{},", ",[266,2116,1852],{}," and ",[266,2119,2120],{},"customer.portal()",". Polar takes care of taxes, invoices and plan changes.",[235,2123,2124,2125,2128],{},"Of course, there are downsides. Every session fetch makes an extra request to Polar, and if Polar is down, my app can't tell who paid. And as soon as you need payment data in your own database, for example to send a welcome email after the first order, you need webhooks again. The plugin has a ",[266,2126,2127],{},"webhooks()"," option for that.",[2130,2131,2132],"tip",{},[235,2133,2134,2135,2137,2138,2141,2142,709],{},"All of this is already set up in ",[239,2136,242],{"href":241},", including the pricing page, the billing dashboard and the lifetime deal check. Take a look at the ",[239,2139,2140],{"href":69},"payment docs"," or click through the ",[239,2143,2146],{"href":2144,"rel":2145},"https:\u002F\u002Fdemo.nuxtstarterkit.com",[251],"live demo",[2148,2149,2150],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}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 .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 .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 .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 .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}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 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}",{"title":306,"searchDepth":352,"depth":352,"links":2152},[2153,2154,2155,2156,2157,2158,2159,2160,2161,2162],{"id":286,"depth":352,"text":287},{"id":296,"depth":352,"text":16},{"id":385,"depth":352,"text":386},{"id":868,"depth":352,"text":869},{"id":1107,"depth":352,"text":1108},{"id":1536,"depth":352,"text":1537},{"id":1614,"depth":352,"text":1615},{"id":2056,"depth":352,"text":2057},{"id":2092,"depth":352,"text":2093},{"id":2107,"depth":352,"text":2108},"2026-11-27","How I sell subscriptions and lifetime deals in Nuxt 4 with Polar's better-auth plugin, and why my app checks access without a single webhook handler.","md",null,{},{"title":168,"description":2164},{"loc":169,"lastmod":2163},[2171,257,73],"Nuxt 4","-FFK3Zzi3GrxU7RVOZeHir7VIuwzx5K8vwD8nDV2k40",[2174,2166],{"title":164,"path":165,"stem":166,"description":2175,"date":2176,"children":-1},"The checklist I use to judge a Nuxt SaaS boilerplate (auth, payments, architecture, security and maintenance), based on the kits I tried before I built my own.","2026-08-08",{"amount":2178,"formatted":2179},99,"$99",1795773603851]