/how-to-build-lovable

How to build Customer portal with Lovable?

Practical guide to build a secure branded customer portal with Lovable. Step by step setup, customization, user roles, integrations, and tips now!

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to build Customer portal with Lovable?

You can build a production-ish Customer Portal entirely inside Lovable by using Chat Mode to add pages, wire client-side auth to Supabase, store secrets in Lovable Cloud, preview the app, and publish — without any terminal. For server-only work (webhooks, secure billing operations) export/sync to GitHub and finish in your own repo (outside Lovable). Below are step-by-step Lovable prompts to paste into Chat Mode so Lovable will make the changes for you.

 

What we’re building / changing

 

Build a basic Customer Portal: sign-in, list subscriptions (from Supabase table), profile page, and a link to manage billing (Stripe) that routes to a secure endpoint you can implement later. Client-side Supabase auth + protected routes inside the app. Server-only billing hooks flagged for GitHub export.

  • Works inside Lovable: UI, routes, Supabase client, secrets via Lovable Cloud, Preview and Publish.
  • Outside Lovable (optional): Secure Stripe webhook handling or service-role operations — do via GitHub export.

 

Lovable-native approach

 

  • Use Chat Mode edits to create React/Next pages and components (file diffs).
  • Use Lovable Cloud Secrets UI to add SUPABASE_URL and SUPABASE_ANON\_KEY.
  • Use Preview to sign-in and test routes. Publish from Lovable when ready.
  • No terminal needed. If you need server-only code with service keys, sync to GitHub and complete there (labeled in prompts).

 

Meta-prompts to paste into Lovable

 

Prompt 1: Scaffold pages + routes
Goal: Create portal pages and protect them with client-side auth.
Files to create/modify:

  • src/pages/_app.tsx (wrap provider)
  • src/pages/index.tsx (public landing)
  • src/pages/portal.tsx (protected portal)
  • src/components/AuthGuard.tsx
  • src/lib/supabase.ts
    Acceptance: Done when /portal redirects to /login if not signed-in; shows subscription list when signed in.
    Secrets: Add SUPABASE_URL and SUPABASE_ANON_KEY in Lovable Cloud Secrets before Preview.
    Instruction for Lovable (include code examples):
    // create src/lib/supabase.ts
    import { createClient } from '@supabase/supabase-js'
    // use process.env for Lovable secrets
    export const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY!)
    // create src/components/AuthGuard.tsx
    import React from 'react'
    import { useRouter } from 'next/router'
    import { supabase } from '../lib/supabase'
    // simple client-side guard
    export default function AuthGuard({ children }) {
    // implement check and redirect to /login
    }
    // create pages/_app.tsx, pages/index.tsx, pages/portal.tsx
    // pages/portal.tsx fetches subscriptions from 'subscriptions' table for current user
    

 

Prompt 2: Add sign-in/out UI and subscription list
Goal: Implement login UI and subscription fetch.
Files:

  • src/pages/login.tsx
  • src/components/SubscriptionList.tsx
    Acceptance: Done when user can sign in via Supabase Magic Link (or email) and see subscriptions rows.
    Instruction:
    // create src/pages/login.tsx with a form that calls supabase.auth.signInWithOtp({email})
    // create src/components/SubscriptionList.tsx that queries supabase.from('subscriptions').select('*').eq('user_id', user.id)
    
    Secrets: Ensure SUPABASE_URL and SUPABASE_ANON_KEY set.

 

Prompt 3: Mark secure billing endpoint for GitHub export
Goal: Add placeholder server endpoint and comment that it requires service role and GitHub export.
Files:

  • server/billing/README.md
  • src/pages/manage-billing.tsx (link to /api/manage-billing)
    Acceptance: Done when UI has “Manage Billing” which links to /api/manage-billing and server/billing/README.md explains next steps (export to GitHub and complete webhook/Stripe secret).
    Instruction:
    // create server/billing/README.md explaining: export to GitHub, add STRIPE_SECRET in host, implement webhook handler with Stripe SDK (terminal required)
    

 

How to verify in Lovable Preview

 

  • Open Preview, go to /login, enter an email -> check Supabase Magic Link arrives. Use a test user you created in Supabase or sign up.
  • After sign-in, visit /portal — you should see the SubscriptionList populated from your Supabase table.
  • Manage Billing button should navigate to /api/manage-billing (shows placeholder message).

 

How to Publish / re-publish

 

  • Use Publish in Lovable Cloud after testing in Preview. Ensure Secrets are set in Lovable Cloud before Publish.
  • If you need server-side secure code (Stripe webhooks or service-role keys), sync/export to GitHub from Lovable and complete those files in your repo; then deploy using your usual CI.

 

Common pitfalls (and how to avoid them)

 

  • Missing Secrets: Preview will fail to auth if SUPABASE\_\* aren't added in Lovable Secrets — add them in the Secrets UI.
  • Service-role operations: Don’t store service keys in client code. Mark those endpoints for GitHub export and implement server-side there.
  • Expect no terminal: Any npm installs or migrations must be done by exporting the project to GitHub and running locally/CI.

 

Validity bar

 

All instructions use Lovable chat edits, Preview, Publish and Lovable Cloud Secrets. Anything requiring CLI is explicitly routed to GitHub export. These are Lovable-native flows only.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

How to add an immutable audit log to your Customer portal

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

How to add a rate limiter to your Lovable customer portal

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

How to add a signed, idempotent webhook receiver

This prompt helps an AI assistant understand your setup and guide to build the feature

AI AI Prompt

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation
Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

Best Practices for Building a Customer portal with AI Code Generators

Build the portal as a secure, minimal backend + frontend system where Lovable generates UI and API scaffolding, but you treat generated code as a starting point — wire real secrets (via Lovable Secrets UI), enforce server-side auth/roles (never expose service keys in client), run DB migrations and package installs outside Lovable (via GitHub CI), and use Lovable Preview/Publish to iterate UI and small server edits. The short rule: use Lovable for design, code edits, and secrets configuration; use GitHub export + your CI/deploy for anything that requires a terminal (migrations, npm install, long-running jobs).

 

Architecture & what to generate with AI

 

  • Prefer thin backend + client: generate auth endpoints, CRUD endpoints, and UI components. Keep heavy logic or secrets on server-only functions.
  • Use Supabase for auth and DB when you want quick product-ready features (auth, storage, realtime). Lovable can scaffold calls but you must configure keys.
  • Guard AI outputs: treat generated code as draft — review for security, missing error handling, and dependency needs.

 

Secrets, environment, and Lovable Cloud

 

  • Never paste secrets into chat. Use Lovable’s Secrets UI to add SUPABASE_URL, SUPABASE_ANON_KEY, SUPABASE_SERVICE_KEY, OPENAI_KEY, etc.
  • Map secrets to env vars your app expects (process.env.SUPABASE\_URL). Confirm in Preview that server-side code reads them.
  • Client vs server keys: only use anon/public keys in browser. Keep service role keys server-only (API routes or edge functions).

 

Previewing, editing, and publishing in Lovable

 

  • Use Chat Mode edits and file diffs to iterate UI and small server code. Use Preview to test workflows with mocked or real secrets.
  • Run functional checks in Preview, but remember Preview is not a full production environment — integrations that require terminal or background processes may behave differently.
  • Publish only stable changes — consider syncing to GitHub for production deployment.

 

When you need GitHub sync / external CI

 

  • Sync to GitHub for installs, migrations, and advanced CI: GitHub Actions (or Vercel/Netlify) runs npm install, build, DB migrations, and deploy.
  • Run migrations outside Lovable — generated migration files must be executed by your CI or local terminal.
  • Use GitHub PRs for code review before deploying to production.

 

Security, auth, and data access

 

  • Implement server-side auth checks on all endpoints. Don’t trust client-sent roles.
  • Prefer Row-Level Security (RLS) in Supabase and call via server endpoints for privileged operations.
  • Rate-limit and log AI/code-generator endpoints to avoid runaway costs or misuse.

 

// pages/api/profile.js
import { createClient } from '@supabase/supabase-js' 
// server-only: service key must be in Lovable Secrets and not exposed to client
const supabase = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_KEY)

export default async function handler(req, res) {
  // ensure user is authenticated via your session cookie or token
  // fetch user profile securely
  const { userId } = req.body
  const { data, error } = await supabase.from('profiles').select('*').eq('id', userId).single()
  if (error) return res.status(500).json({ error: error.message })
  return res.json({ profile: data })
}

 

Final practical checklist

 

  • Generate with Lovable, review by humans.
  • Store secrets in Lovable Secrets UI and map to env vars used in code.
  • Use Preview for UI and small server tests, but run migrations and builds via GitHub/CI.
  • Keep service keys server-side, use RLS and server endpoints to enforce permissions.
  • Sync to GitHub when you need terminal actions or production CI/CD.

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022