Lead Capture API Reference
Table of Contents
The Lead Capture Plugin makes it super easy to collect email leads in your FastStartup project. Whether you’re validating ideas, growing a waitlist, or starting a newsletter—this plugin has you covered.
It’s simple, effective, and integrates seamlessly with your FastStartup setup.
Overview
Lead Capture is built to do one thing well: collect email addresses.
It exports two main tools:
LeadCaptureForm
– A headless form component for capturing emails.collectEmail
– A function to validate and save emails to your database.
To save the emails, you need the Database API. Set it up here.
Once your database is ready, you can start capturing emails in minutes.
Key Features
- Headless Form: Use
LeadCaptureForm
to collect emails without UI restrictions. - Easy Validation: The
collectEmail
function ensures emails are valid before saving. - Database Integration: Seamlessly store captured emails in your database.
Use Cases
- Idea Validation: Collect early interest for your new product.
- Waitlist Growth: Build a list of potential users before launch.
- Newsletter Signup: Capture emails for your content updates.
Getting Started
First, make sure the Database API is set up and then you can import the lead capture form.
Step 1: Import and Use LeadCaptureForm
Here’s an example of how to use the LeadCaptureForm
in a page:
import { LeadCaptureForm } from "@/plugins/leadCapture";
export default function Home() {
return (
<div>
<h1>Join the Waitlist</h1>
<LeadCaptureForm />
</div>
);
}
That’s all you need! The LeadCaptureForm
handles everything under the hood.
Step 2: Use collectEmail
(Optional)
If you want to save emails manually, use collectEmail
like this:
import { collectEmail } from "@/plugins/leadCapture";
async function handleSubmit(email: string) {
const success = await collectEmail(email);
if (success) {
alert("Email saved successfully!");
} else {
alert("Something went wrong.");
}
}
API Overview
Here’s a quick look at the plugin’s API:
Function / Component | Description |
---|---|
LeadCaptureForm | A prebuilt headless form to collect emails. |
collectEmail | Validates and saves email to the database. |
Comparison to Alternatives
Most email collection tools require third-party integrations or bloated dependencies.
With the Lead Capture Plugin:
- No Dependencies: Everything runs natively inside FastStartup.
- Customizable: Use the form however you like—no UI lock-in.
- Built-in Storage: Emails are saved to your own database.
No need to pay for external email tools or embed third-party scripts.
FAQ
1. Do I need the Database API? Yes. The Database API is required to store emails.
2. Can I style the LeadCaptureForm? Yes! It’s headless, so you can style it any way you want.
3. Is validation included?
Yes. collectEmail
automatically validates the email before saving it.
4. Can I use this with custom forms?
Yes. Use collectEmail
to handle email submission from any form.
5. How do I install the Database API? Check out the Database API docs.
That’s it! The Lead Capture Plugin keeps things simple and effective.
Start capturing leads today and grow your audience the FastStartup way.