Memberstack for Bolt
Paid memberships for your Bolt app, live on bolt.host
Keep building in Bolt. Run one install in its terminal, and Memberstack runs your logins, Stripe plans and members-only pages.
In Bolt
Bolt's own login runs on Bolt Database. Name Memberstack so members log in one place.
On your live app
“Great service - I am very impressed by how easy it is to integrate their service into an existing site.”
Seven steps, in order
One command in Bolt's terminal, one value in .env, and short messages to Bolt. The code is what Bolt should write, so you can check it.
Copy your public key
It's in your Memberstack dashboard and starts with pk_. It's safe in the browser. Your secret key never goes in a Bolt project.
Put it in .env, not Secrets
Bolt keeps environment variables in your project's .env file, where code in the browser can read them. Bolt's Secrets only work with server functions. In a Vite project, browser values start with VITE_.
.env
VITE_MEMBERSTACK_PUBLIC_KEY=pk_your_public_key
Install the SDK in Bolt's terminal
Open Code view with the <> icon at the top, then the Terminal tab. Wait until Bolt finishes its reply before you run it. Commands there don't use tokens.
npm install @memberstack/dom
Set up the SDK with your key
Ask Bolt to create this file, or add it yourself in Code view. Editing files there doesn't use tokens either.
src/lib/memberstack.ts
import memberstackDOM from "@memberstack/dom";
export const memberstack = memberstackDOM.init({
publicKey: import.meta.env.VITE_MEMBERSTACK_PUBLIC_KEY, // pk_..., from .env
});Use Memberstack for login, not Bolt Database
Bolt has its own sign-up and login in Bolt Database. Pick one place for members to log in: say Memberstack handles it. The Log in and Sign up buttons open Memberstack's modals.
// Run SDK calls in the browser: click handlers or useEffect.
// Modals stay open after a successful login or sign-up, so close them.
async function open(kind: "LOGIN" | "SIGNUP") {
const { type } = await memberstack.openModal(kind);
if (type !== "CLOSED") memberstack.hideModal();
}
<button onClick={() => open("LOGIN")}>Log in</button>
<button onClick={() => open("SIGNUP")}>Sign up</button>Gate pages by plan
Members-only pages check the member's plans. Only ACTIVE or TRIALING plans get in. Everyone else sees a link to your plans.
src/components/MembersOnly.tsx
import { useEffect, useState } from "react";
import { memberstack } from "@/lib/memberstack";
const PRO_PLAN_ID = "pln_pro"; // your plan ID from the Memberstack dashboard
type Member = { planConnections?: { planId: string; status: string }[] } | null;
// Only ACTIVE or TRIALING plans get in
const hasPro = (member: Member) =>
!!member?.planConnections?.some(
(p) => p.planId === PRO_PLAN_ID && (p.status === "ACTIVE" || p.status === "TRIALING"),
);
export function MembersOnly({ children }: { children: React.ReactNode }) {
const [state, setState] = useState<"loading" | "allowed" | "blocked">("loading");
useEffect(() => {
const ms = memberstack;
// Check now, then again whenever someone logs in, signs up or logs out
ms.getCurrentMember().then(({ data }) => setState(hasPro(data) ? "allowed" : "blocked"));
const { unsubscribe } = ms.onAuthChange((member) =>
setState(hasPro(member) ? "allowed" : "blocked"),
);
return () => {
unsubscribe();
};
}, []);
if (state === "loading") return null;
if (state === "blocked") return <p>Members only. <a href="/pricing">See plans</a>.</p>;
return <>{children}</>;
}Take payments with Memberstack's Checkout
Upgrade buttons open Stripe Checkout. When the member comes back, the plan is already on their account.
// Upgrade button: Stripe Checkout, then back to your app
await memberstack.purchasePlansWithCheckout({
priceId: "prc_pro_monthly", // your Memberstack price ID (prc_...)
successUrl: "/members",
cancelUrl: "/pricing",
});Hiding a page isn't protecting it
The plan check decides what the browser shows. If a file or an API response must stay private, verify the member token on your server with @memberstack/admin and verifyToken, passing your app ID as the audience.
Or send Bolt one message
Run the install first. Then swap in your plan and price IDs from the Memberstack dashboard and paste this into Bolt's chat.
Don't use Bolt Database for sign-up and login; Memberstack handles members. Initialise @memberstack/dom in src/lib/memberstack.ts with my public key from VITE_MEMBERSTACK_PUBLIC_KEY in .env. The Log in and Sign up buttons call memberstack.openModal("LOGIN") and memberstack.openModal("SIGNUP"), then close it with hideModal() once the member is in. Only let members with plan pln_pro whose status is ACTIVE or TRIALING see /members, and re-check when someone logs in or out. Add an upgrade button that starts Stripe Checkout for price prc_pro_monthly.Bolt and Memberstack questions answered
Setup, plans, payments and security.
No. Run one install command in Bolt's terminal, then paste the prompt on this page with your own plan and price IDs. The code on this page is what the result looks like, so you can check what Bolt produced in Code view.
No. Pick one place for members to log in. Bolt's own sign-up and login run on Bolt Database, so say in the prompt that Memberstack handles members.
In your project's .env file. Bolt says environment variables there can be read by code in the browser, which is what the public key needs. Bolt's Secrets only work with server functions. Your Memberstack secret key never goes in the project.
React with Vite. Bolt picks a framework when you start a project, and you can name one in your prompt. If yours is different, the SDK calls are the same; only the way you read .env values changes.
Not the terminal step. In Safari and on phones, Bolt's Code view is read-only and the terminal isn't available, so run the install on a computer in Chrome or another Chromium browser.
Click Publish at the top right. Bolt publishes to a free bolt.host address on both Free and Pro plans.
Paid plans use Stripe Checkout. Your app calls purchasePlansWithCheckout with a Memberstack price ID (prc_...), the member pays on Stripe's page, and they come back to your app with access already granted. Free plans use a plan ID (pln_...) and are added with addPlan.
A plan connection grants access when its status is ACTIVE or TRIALING. Other statuses, such as REQUIRES_PAYMENT when a Stripe payment fails, do not grant access.
No. Client-side checks only control what the browser shows. Anything sensitive, such as a file or an API response, should be checked on your server with @memberstack/admin and verifyToken, passing your app ID as the audience.
Your Bolt app, with members
Keep your members on Memberstack.
Logins, Stripe plans and members-only pages for the app you built in Bolt.
- No credit card required
- Same members on every platform


