/how-to-build-lovable

How to build Online quiz app with Lovable?

Build an online quiz app with Lovable using step by step guides, templates, auth, scoring and analytics to launch faster and engage learners.

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 Online quiz app with Lovable?

You can build a simple, production-ready online quiz in Lovable by iterating in Chat Mode: create React pages and a questions JSON, wire UI + state, optionally add Supabase for persistence via Lovable Secrets, preview interactively, and Publish when ready — all without a terminal. Below are copy-paste prompts you can paste into Lovable’s chat to implement the app step-by-step.

 

What we’re building / changing (plain English)

 

A single-page React quiz app with a Home page, a Quiz flow that shows multiple-choice questions, scoring, a Results page, and an optional Supabase-backed submit for storing scores. Works entirely through Lovable chat edits, Preview, Secrets UI and Publish (no terminal).

 

Lovable-native approach

 

We’ll use Chat Mode edits to create files (components/pages/data), Preview to test the UI, Secrets UI to store SUPABASE_URL and SUPABASE_ANON\_KEY if you want persistence, and Publish to publish the site. For advanced server code or migrations you’ll export to GitHub (outside Lovable) — I’ll call that out where needed.

 

Meta-prompts to paste into Lovable

 

Prompt 1: Create basic app structure and questions

  • Goal: Add pages and static question data so the quiz runs locally in Preview.
  • Files to create/modify:
    • src/pages/Home.tsx — create
    • src/pages/Quiz.tsx — create
    • src/pages/Results.tsx — create
    • src/App.tsx — update to add routes
    • src/data/questions.json — create
  • Acceptance criteria: Done when Preview shows a Home page with a “Start Quiz” button, Quiz navigates through questions, and Results shows final score.
// Create src/data/questions.json
[
  {
    "id": 1,
    "text": "What color is the sky on a clear day?",
    "choices": ["Blue","Green","Red","Yellow"],
    "answer": 0
  },
  {
    "id": 2,
    "text": "2 + 2 = ?",
    "choices": ["3","4","5","22"],
    "answer": 1
  }
]

// Update src/App.tsx
// Ensure React Router is present; if not, create a minimal SPA routing
import React from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import Home from './pages/Home';
import Quiz from './pages/Quiz';
import Results from './pages/Results';

export default function App(){
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Home/>}/>
        <Route path="/quiz" element={<Quiz/>}/>
        <Route path="/results" element={<Results/>}/>
      </Routes>
    </BrowserRouter>
  );
}

 

Prompt 2: Implement quiz logic UI

  • Goal: Implement Quiz page state: current question, choose answer, next, finish and pass score to Results via location state or URL param.
  • Files to modify: src/pages/Quiz.tsx, src/pages/Results.tsx
  • Acceptance criteria: Done when selecting answers and clicking Next updates score; Finish navigates to /results and Results displays score.
// Update src/pages/Quiz.tsx
// Load questions from src/data/questions.json, render choices, track score and navigation

// Update src/pages/Results.tsx
// Read score (location.state or query) and display it with a "Submit score" button (Supabase optional)

 

Prompt 3: (Optional) Add Supabase submit integration

  • Goal: Save quiz results to a Supabase table when user clicks "Submit score."
  • Files to create/modify: src/lib/supabase.ts (create), src/pages/Results.tsx (modify)
  • Secrets/Integration: In Lovable Cloud, add Secrets SUPABASE_URL and SUPABASE_ANON_KEY via the Secrets UI. Also create a Supabase project and a table "quiz_results" with columns: id (uuid), name (text), score (int), created\_at (timestamp) — done in Supabase dashboard (no terminal required).
  • Acceptance criteria: Done when clicking "Submit score" returns success and a new row appears in Supabase table.
// Create src/lib/supabase.ts
// Use @supabase/supabase-js — if package missing, add dependency through Lovable package.json edit
import { createClient } from '@supabase/supabase-js';
const supabaseUrl = process.env.REACT_APP_SUPABASE_URL;
const supabaseKey = process.env.REACT_APP_SUPABASE_ANON_KEY;
export const supabase = createClient(supabaseUrl!, supabaseKey!);

 

How to verify in Lovable Preview

 

  • Open Preview, click Start Quiz, answer questions, confirm Next and Finish flows work and Results shows correct score.
  • If Supabase enabled, click Submit score and confirm success message; check Supabase dashboard for a new row.

 

How to Publish / re-publish

 

  • Use Lovable Publish button to publish the site. Changes saved via Chat Mode edits are included. If you added Secrets, ensure they’re set in Lovable Cloud before publish.
  • Advanced deployment or server code: Export/sync to GitHub from Lovable and deploy/run CI outside Lovable (terminal/CI required). I’ll mark any steps that need that as "outside Lovable (terminal required)".

 

Common pitfalls in Lovable (and how to avoid them)

 

  • Forgetting to set Secrets: Add SUPABASE_URL and SUPABASE_ANON\_KEY in Lovable Cloud Secrets UI; Preview uses them.
  • Missing dependency: If you add @supabase/supabase-js, update package.json in Lovable project (Chat Mode) — Preview will install automatically in Lovable environment.
  • Routing issues: Use BrowserRouter; if preview path routing fails, open Preview root route or use HashRouter as fallback.
  • Server migrations: Creating DB schema must be done in Supabase dashboard (no CLI). If you need server code, export to GitHub for CI/hosting.

 

Validity bar

 

This plan uses only Lovable-native features: Chat Mode file edits, Preview, Secrets UI, Publish and GitHub export. Anything requiring a terminal (running migrations or backend processes outside Supabase dashboard) is explicitly labeled as outside Lovable and requires GitHub export and local/CI steps.

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 per-user & per-IP rate limiting to quiz submissions

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

AI AI Prompt

How to add a cheat detector to a Lovable quiz app

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

AI AI Prompt

How to add server-side draft autosave for quiz answers

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 Online quiz app with AI Code Generators

A focused short answer: build the quiz UI and auth like any web app, use AI only for content generation and grading with server-side calls, protect API keys using Lovable Secrets UI, iterate in Lovable via Chat Mode + Preview + Publish, persist quizzes and provenance (prompt + model + timestamp) in your DB (e.g., Supabase) and cache generated content to avoid repeated AI calls. Keep human review and deterministic prompts for grading, rate-limit and fallback to deterministic scoring, and use GitHub export/sync when you need CLI work (migrations, custom builds).

 

Practical design & architecture

 

Keep AI at the edges: use the model to generate question text, distractors, explanations, and to grade free-text answers — but store outputs in your DB and show them as normal content. Treat AI results as data, not business logic.

  • Server-side only for model calls — never call OpenAI from client. Use Lovable’s server (Publish -> cloud) or an API route that uses Secrets, so keys stay secret.
  • Store provenance — save prompt, model name, temperature, and raw response with each generated quiz item for auditing and re-generation.
  • Human-in-the-loop — provide a review UI for human editors to accept/modify generated questions before publishing to learners.

 

Lovable-specific workflow

 

  • Iterate with Chat Mode to change prompts, UI, or routes; use diffs/patches to update files.
  • Preview every change (simulate auth and sample data) before Publish.
  • Set API keys in Secrets UI (OPENAI_KEY, SUPABASE_URL, SUPABASE\_KEY) — don’t hardcode.
  • Use GitHub export/sync only if you need migrations, custom CI, or local CLI tools; remember Lovable has no terminal.

 

AI prompt & reliability best practices

 

  • Prompt templates with variables (topic, difficulty, format). Keep low temperature for deterministic grading.
  • Validation — sanity-check generated options (no duplicates, correct answer included, length limits).
  • Rate limit and cache — store generated quizzes in DB and reuse; fall back to cached version on API errors.

 

Security, privacy, and compliance

 

  • Secrets UI for keys; rotate regularly.
  • PII — avoid sending user PII to model; redact or hash if needed.
  • Logging — log only metadata, not full user answers unless consented.

 

Small working example: server endpoint to generate a 4-choice question

 

// pages/api/generate-question.js (Next.js style serverless API)
// Uses OPENAI_KEY from Lovable Secrets set into process.env.OPENAI_KEY
export default async function handler(req, res) {
  // Validate request body
  const { topic = "photosynthesis", difficulty = "easy" } = req.body || {};
  const prompt = `Create one ${difficulty} multiple-choice question about ${topic}. 
Return JSON: {"question":"...","choices":["..."],"correct_index":0,"explanation":"..."}.`;
  const r = await fetch("https://api.openai.com/v1/chat/completions", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": `Bearer ${process.env.OPENAI_KEY}`
    },
    body: JSON.stringify({
      model: "gpt-4",
      messages: [{ role: "user", content: prompt }],
      temperature: 0.2,
      max_tokens: 400
    })
  });
  const data = await r.json();
  // Simple parse and save logic would follow (sanitize before DB)
  res.status(200).json({ raw: data });
}

 

Quick grading approach

 

  • Structured answers — prefer multiple choice for instant deterministic scoring.
  • Free-text grading — call model with low temperature and explicit rubric, then save grade + rationale.
  • Fallback — if model is unavailable, flag for manual grading.

 

// Example: send student's free-text answer for grading
// Keep temperature low for deterministic scoring
const gradePrompt = `Rubric: be concise. Question: "${q}". Student answer: "${a}". Return JSON {"score":0-1,"explanation":"..."}`

 

Final practical notes: iterate UI in Lovable Chat Mode, keep secrets in Secrets UI, persist AI outputs and prompts for audit, and use GitHub sync only when you need external tooling. Test failures and edge cases locally via GitHub export if you must run migrations or use CLI tools — otherwise the Lovable Preview + Publish cycle is sufficient for production-ish deployments.

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