env NEON_CONNECTION_STRING This document explains how to use the contact form component with Neon database integration.
The contact form implementation uses the Neon serverless PostgreSQL database to store form submissions. This approach provides:
/api/contact-serverless.ts - Handles form submissions and stores data in Neonsrc/utils/db/neon-serverless.ts - Provides connection to Neon databasesrc/components/ContactForm.jsx - Reusable contact form componentsrc/utils/db/schema.sql - Includes the contact_submissions table definitionimport ContactForm from '../components/ContactForm';
export default function ContactPage() {
return (
<div className="container mx-auto py-12">
<h1 className="text-3xl font-bold mb-6">Contact Us</h1>
<ContactForm />
</div>
);
}
You can specify the type of contact form:
<ContactForm type="speaking" />
Available types:
general (default)speakingmediaThe contact_submissions table has the following structure:
CREATE TABLE contact_submissions (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
organization TEXT NOT NULL,
message TEXT NOT NULL,
type TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
status TEXT DEFAULT 'new',
additional_data JSONB,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
Ensure your Neon database connection string is set in your environment variables:
NEON_CONNECTION_STRING=postgres://user:password@endpoint.neon.tech/neondb
Run the setup script to create the necessary table:
node scripts/db/setup-contact-table.js
Import and use the ContactForm component in your pages.
You can customize the form by modifying the ContactForm.jsx component. The component is designed to be flexible and can be extended with additional fields as needed.