Created
June 28, 2024 12:36
-
-
Save Joeldorne/faa3bb9719e541f8bd24b137f22e3d56 to your computer and use it in GitHub Desktop.
Supabase Server Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "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