Contact Forms
Handle storefront contact form submissions.
Updated
On this page
Overview
Accept contact form submissions from your storefront. Submissions are stored in the dashboard and can trigger email notifications.
SDK Usage
import dash from "@/lib/dash"
const { success, message, submission_id } = await dash.contact.submit({
name: "Jane Doe",
email: "jane@example.com",
content: "I have a question about my order...",
phone: "555-0123", // optional
subject: "Order Question", // optional
source_url: window.location.href, // optional
turnstile_token: "...", // optional captcha
})
Contact Form Component
"use client"
import { useState } from "react"
import dash from "@/lib/dash"
export function ContactForm() {
const [form, setForm] = useState({ name: "", email: "", content: "" })
const [status, setStatus] = useState<"idle" | "sending" | "sent" | "error">("idle")
async function handleSubmit(e) {
e.preventDefault()
setStatus("sending")
try {
await dash.contact.submit(form)
setStatus("sent")
} catch {
setStatus("error")
}
}
if (status === "sent") return <p>Thank you! We'll get back to you soon.</p>
return (
<form onSubmit={handleSubmit}>
<input placeholder="Name" required
value={form.name} onChange={e => setForm(f => ({...f, name: e.target.value}))} />
<input placeholder="Email" type="email" required
value={form.email} onChange={e => setForm(f => ({...f, email: e.target.value}))} />
<textarea placeholder="Message" required
value={form.content} onChange={e => setForm(f => ({...f, content: e.target.value}))} />
<button type="submit" disabled={status === "sending"}>
{status === "sending" ? "Sending..." : "Send Message"}
</button>
{status === "error" && <p className="text-red-500">Something went wrong. Please try again.</p>}
</form>
)
}
REST API
POST /storefront/contact
X-API-Key: pk_live_your_key
Content-Type: application/json
{
"name": "Jane Doe",
"email": "jane@example.com",
"content": "I have a question about my order...",
"subject": "Order Question"
}
Viewing Submissions
All contact form submissions appear in the dashboard under Contacts. You can reply to them, mark as resolved, and view submission details.
Next Steps
- Form Setup — Advanced form configuration
- Submissions API — Managing submissions programmatically