Skip to content

Instantly share code, notes, and snippets.

@Joeldorne
Created June 28, 2024 12:36
Show Gist options
  • Select an option

  • Save Joeldorne/faa3bb9719e541f8bd24b137f22e3d56 to your computer and use it in GitHub Desktop.

Select an option

Save Joeldorne/faa3bb9719e541f8bd24b137f22e3d56 to your computer and use it in GitHub Desktop.
Supabase Server Action
"use server"
import { createClient } from '@supabase/supabase-js'
// Make sure to set these environment variables
const supabase = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE_KEY!)
export async function submitForm(data: { name: string, email: string }) {
const { data: result, error } = await supabase
.from('your_table_name') // Replace with your actual table name
.insert([data])
if (error) throw error
return { success: true, message: "Form submitted successfully" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment