1 min read
Vercel Postgres is a serverless PostgresSQL database, designed to integrate with Vercel Functions and any frontend framework.
app/page.tsx
import { sql } from '@vercel/postgres';import { redirect } from 'next/navigation';
async function create(formData: FormData) { 'use server'; const { rows } = await sql` INSERT INTO products (name) VALUES (${formData.get('name')}) `; redirect(`/product/${rows[0].slug}`);}
export default function Page() { return ( <form action={create}> <input type="text" name="name" /> <button type="submit">Submit</button> </form> );}
Use Vercel Postgres with Next.js Server Actions (to be announced Thursday)
Vercel Postgres is available for Hobby and Pro users during the public beta.
Check out our documentation or get started with a template: