Introducing Paid and Protected Pages
Learn how LaunchFa.st helps you create authenticated and paid pages to prevent un-paid and un-authenticated access.
LaunchFa.st comes with baked-in paid and protected page(s) to help you prevent un-paid and un-authenticated users access such pages. With the payment methods such as Stripe and Lemon Squeezy integrated in LaunchFa.st and authentication methods such as Google, Twitter and Credentials, such payment callbacks’ and user authentication methods can be used by your system to grant access only to the paid and authenticated users to paid and protected pages in your application.
Here’s how easily you can create paid and protected pages with LaunchFa.st:
- Create a file, say
paid_and_protected.astrowith the following code:
---import redis from '@/lib/db/upstash'import { getSession } from '@/lib/utils/auth'
const session: any = getSession(Astro.cookies)
if (!session) return webResponse('Unauthorized', 403, {})
if (session?.email) { const paid = await redis.hget('access', session.email) if (paid !== 1) return webResponse('Unauthorized', 403, {})}---
<html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> </head> <body class="font-display"> <div class="relative mx-auto flex max-w-7xl flex-col px-8 sm:px-4 py-8"> <h1 class="pb-6 text-3xl font-medium text-launchfast">Paid and Protected Content!</h1> </div> </body></html>- That’s it! The Upstash Redis instance integrated in the LaunchFast Starter Kit takes care of fetching the user paid status and the
getSessionfunction takes care of decoding the user authentication status. If unauthorized or not paid, a 403 response is sent enforcing pay and authentication based access to the content.
Worry not, with LaunchFa.st you get such a page paid_and_protected.astro built for you with goodies on top.
Continue reading
Incremental static builds in Astro 7.2: cutting my rebuild time by 39%
How Astro 7.2 incremental static builds cut a one-post rebuild from ~16.5s to ~10s, restoring 637 of 661 pages from cache with the right cacheKey setup.
MailKite Email Support Now Available in LaunchFast Starter Kits
We're excited to announce that MailKite email support is now available in all LaunchFast starter kits. Send transactional emails through MailKite with a single environment variable change.
Astro Islands: when NOT to Hydrate
Hydration is expensive. A practical look at Astro islands: the cheaper options to exhaust first (static HTML, build-time data, server islands, progressive enhancement), and the cases where hydration is useful.