Back to Learn

    Build a SaaS on Lovable: The Foundation Prompt, the Schema That Proves Its Policies, and the Billing Step

    A SaaS is a multi-tenant app plus the machinery that lets strangers pay for it without reading each other's data. This page is the order that machinery gets built on Lovable, taken from the kit this site ships: the foundation prompt, which was run for a measured number of credits; the schema, whose tables, policies and verification checks are counted from the file at build time; the mechanics prompts that make the app chargeable; and billing, last, with the rule that keeps it honest. The Cadence build from earlier today is the worked example, and what it still lacks is listed.

    Updated

    Build a SaaS hero: the title beside a card, foundation prompt with auth, roles and invites at 10.4 credits, kit schema with 4 tables, 12 policies and 6 checks, run verify.sql as a member and expect denials, landing page first and billing last, the webhook is the only writer of entitlement, what is still unbuilt listed

    What order avoids rework?

    The one where each step is proven before the next depends on it. Accounts before roles, roles before any screen that hides by role, the schema before the features that write to it, a landing page before billing, and billing wired so the webhook is the only thing that grants access.

    Building a SaaS on Lovable, in order
    1Foundationprompt, 10.4 cr2Schemakit migration3Verifyas a member4Landing pagecount sign-ups5Mechanicslimits, trial6Billingwebhook writes
    1. Foundation: prompt, 10.4 cr
    2. Schema: kit migration
    3. Verify: as a member
    4. Landing page: count sign-ups
    5. Mechanics: limits, trial
    6. Billing: webhook writes

    The SaaS starter kit's setup steps and the SaaS prompts' build orders, condensed.

    Step one: the foundation prompt, and what it cost

    The prompt is SaaS MVP with User Auth from the SaaS prompts: email and password auth that survives refresh, a workspace on first sign-in, three roles, invite by tokenised link, role-gated UI, and the safeguard that roles are enforced in the database. Run on 2026-09-26 for 10.4 credits: it asked 4 questions, enabled Cloud, self-tested sign-up and invites, roles checked in the database.

    Lovable asking for approval to run its own end-to-end test of the invite flow during the SaaS foundation build
    Lovable asking to self-test the invite flow during the foundation build, 2026-09-26.

    The prompt examples page has the four questions it asked first and the rest of the screenshots.

    Step two: the schema, counted from the file

    The SaaS starter kit ships the database the foundation prompt expects. The numbers below are read from its files when this page is built, so they cannot drift from what you download.

    The SaaS starter kit's schema, counted at build time
    Tables4RLS policies12Helper functions4Verification statements6
    The SaaS starter kit's schema, counted at build time
    Categorycount
    Tables4
    RLS policies12
    Helper functions4
    Verification statements6

    src/data/templates.ts, read 26 September 2026. Tables: profiles, workspaces, workspace_members, workspace_invites.

    The kit's setup order, from its own steps
     Detail
    Run schema.sql in the Supabase SQL editorBefore prompting Lovable. The prompt references these table names, so building first means rework.
    Run verify.sql as an ordinary signed-in userNot as service_role, which bypasses every policy and will make a broken schema look correct.
    Paste prompt.md into LovableUnedited on the first pass, so you can see what the structure produces before changing it.
    Replace the audience lineThe Context section names a small team adopting a tool. Changing that one line changes which features Lovable prioritises more than anything else in the prompt.

    The traps the kit was written around: a recursive policy on the membership table, and a member promoting themselves to owner through an update policy without a with-check clause. The Lovable and Supabase guide has the three shapes of that failure.

    Step three: prove the policies deny

    Lovable's Quick and Deep scans confirm that row-level security is present on a table. Neither runs a query as the wrong user, which is the only proof a policy denies. The kit's verify.sql does: sign in as an ordinary member, read another workspace's rows, promote yourself to owner, and expect both to fail. On the Cadence build the Deep scan reported nothing at any severity and the dependency panel listed two known issues; the security page has the run and the distinction.

    -- Verification queries. Run these as an ordinary signed-in user, not as service_role.
    -- Every one of them must behave as described or a policy is wrong.
    
    -- 1. Should return only workspaces you are a member of, never every workspace.
    select id, name, plan from public.workspaces;
    
    -- 2. Should return zero rows for a workspace you do not belong to.
    --    Substitute a workspace id you are NOT a member of.
    select * from public.workspace_members
    where workspace_id = '00000000-0000-0000-0000-000000000000';
    
    -- 3. Should FAIL for a member (non-admin). If it succeeds, the write policy is too loose.
    insert into public.workspace_members (workspace_id, user_id, role)
    values ('<a workspace where you are role=member>', auth.uid(), 'owner');
    ...

    Step four: the landing page, before billing

    A SaaS with no sign-ups does not need a checkout. The six-section SaaS landing page prompt was run on 26 September 2026 for 4.5 credits in a separate project so its analytics stay clean; it counts sign-ups against visitors from one channel, which decides whether steps five and six are worth building.

    The Cadence build so far: 20.4 credits across five steps
    Foundation10.4 (12:26)SEO review1.1 (14:29)Security1.3 (18:06)Installable3.1 (18:36)Landing page4.5 (19:19)
    The Cadence build so far: 20.4 credits across five steps
    Categorycredits
    Foundation10.4 (12:26)
    SEO review1.1 (14:29)
    Security1.3 (18:06)
    Installable3.1 (18:36)
    Landing page4.5 (19:19)

    Composed from the run files in src/data/mvpLedger.ts, 26 September 2026.

    Steps five and six: the mechanics, then billing

    The SaaS category holds 15 mechanics prompts. The five that turn a working app into a chargeable one, in the order their build sections assume:

    The mechanics prompts a SaaS needs before it can charge, from the library
     What it adds
    Subscription Checkout FlowA Stripe subscription flow whose states all exist: checkout, success, failure, cancel, and the webhook that keeps the app honest.
    Payment History & Billing PagesCustomer-facing billing: invoice history, payment method management, and plan changes, driven by Stripe as the source of truth.
    SaaS Teams & Permissions ManagerTeam management for an existing multi-tenant app: role changes, removals, and transfers that hold up in the database, not just the UI.
    SaaS Usage Limits & Quotas ManagerPlan-tier limits that are enforced where they must be and visible where they help: server-side gates with honest usage meters in the UI.
    SaaS Trial Expiration FlowA trial that actually ends: countdown, honest lockout, data retention, and the reactivation path, driven by dates on the server.

    Billing itself is the Lovable and Stripe page: built-in payments on a paid plan or your own key on Free, Stripe's rule that the success page is not proof of payment, and this site's own webhook with its two idempotency layers. The rule that survives every path: the webhook is the only writer of entitlement, and the member page only reads.

    What do the top results for this term leave out?

    • Base44, How to build a SaaS product. About 2,400 words, 10 May 2026, eight steps, three third-party statistics, no build shown; the CTA is the builder.
    • Syndicode, How to Build a SaaS Product. About 8,500 words, 2023, eight steps, a hypothetical estimate of $174,000 to $396,000 and 44 to 82 weeks; agency case studies; the CTA is the agency.
    • A Medium post on building a SaaS in five hours with AI. Blocked to our fetch, so it is listed, not characterised.

    What we did not publish

    • Steps five and six as runs. The mechanics prompts and the billing step are documented, not executed on Cadence; the page says which steps carry a credit figure and which do not.
    • A customer. The build has no users and no revenue; the landing page exists to find out whether it should.
    • A timeline in weeks. The measured day is on the how-to-build-an-MVP page; extrapolating it to a launch would be a guess.

    Sources

    Kit counts from src/data/templates.ts at build time; runs from src/data/runs.ts and src/data/mvpLedger.ts; read 26 September 2026.

    Frequently asked

    How do you build a SaaS with Lovable?↓
    In the order the kit encodes: the foundation prompt for accounts, workspaces, roles and invites; the schema with row-level security applied as a migration; the verification queries run as a member, expecting denials; then the mechanics prompts for checkout, limits and trials; billing last, with the webhook as the only writer. The foundation ran on 26 September 2026 for 10.4 credits and the schema counts 12 policies on 4 tables, read from the file at build time.
    What does the SaaS starter kit contain?↓
    Three files: the build prompt, a schema with 4 tables (profiles, workspaces, workspace_members, workspace_invites), 12 row-level security policies and 4 helper functions, and 6 verification statements that run as an ordinary user rather than the service role. The prompt is free to download; the schema and verification files ship in full with the bundle.
    Why run verification queries as a member and not as admin?↓
    Because the service role bypasses every policy, so testing with it makes a broken schema look correct. The kit's checks sign in as an ordinary member, try to read another workspace's rows and try to promote themselves to owner, and expect both to be denied. Lovable's security scans confirm policies exist; only this proves they deny.
    How much does it cost to build a SaaS this way?↓
    The measured day on this site: 20.4 Lovable credits for the foundation, an SEO review, a security scan, an installable build and a landing page, on a $25 Pro plan that includes 100 credits. Agency guides ranking for this query estimate $174,000 to $396,000 and 44 to 82 weeks for a comparable product; the difference is the team and the custom code, not the SaaS.
    When do you add payments?↓
    Last, after a landing page has counted sign-ups against visitors. Lovable offers built-in payments on paid plans and a Free-plan path with your own Stripe key; on that path the integration uses no webhooks by default, so ask for one and make it the only writer of entitlement. The Lovable and Stripe page has the docs quoted and this site's own webhook.
    What is still unbuilt after the foundation?↓
    Everything a paying customer exposes: the subscription checkout, plan limits enforced server-side, the trial that ends, billing pages, and the audit log a business buyer asks for. Each is a mechanics prompt in the SaaS category; the order that avoids rework is on this page, and the SaaS ideas page composes them per product.

    Related reading

    Written by

    Marco Kohns

    Marco Kohns

    Founder of ProtoBites - Venture Growth Studio

    Growth PM at a Silicon Valley scale-up (a16z and General Catalyst backed), ex-Techstars where he consulted 13 early-stage startups, Reforge-trained. Every prompt on this site comes out of shipping ProtoBites' own portfolio products.