--- title: 'Use Supabase with Next.js' subtitle: 'Learn how to create a Supabase project, add some sample data, and query from a Next.js app.' breadcrumb: 'Framework Quickstarts' hideToc: true --- <$Partial path="quickstart_db_setup.mdx" /> Use the `create-next-app` command and the `with-supabase` template, to create a Next.js app pre-configured with: - [Cookie-based Auth](/docs/guides/auth/server-side/creating-a-client?queryGroups=package-manager&package-manager=npm&queryGroups=framework&framework=nextjs&queryGroups=environment&environment=server) - [TypeScript](https://www.typescriptlang.org/) - [Tailwind CSS](https://tailwindcss.com/) <$Partial path="uiLibCta.mdx" /> ```bash npx create-next-app -e with-supabase ``` Rename `.env.example` to `.env.local` and populate with your Supabase connection variables: <$CodeTabs> ```text name=.env.local NEXT_PUBLIC_SUPABASE_URL= NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY= ``` <$Partial path="api_settings_steps.mdx" variables={{ "framework": "nextjs", "tab": "frameworks" }} /> Create a new file at `app/instruments/page.tsx` and populate with the following. This selects all the rows from the `instruments` table in Supabase and render them on the page. <$CodeTabs> ```ts name=app/instruments/page.tsx import { createClient } from "@/lib/supabase/server"; import { Suspense } from "react"; async function InstrumentsData() { const supabase = await createClient(); const { data: instruments } = await supabase.from("instruments").select(); return
{JSON.stringify(instruments, null, 2)}
; } export default function Instruments() { return ( Loading instruments...}> ); } ```
Run the development server, go to http://localhost:3000/instruments in a browser and you should see the list of instruments. ```bash Terminal npm run dev ```
## Next steps - Set up [Auth](/docs/guides/auth) for your app - [Insert more data](/docs/guides/database/import-data) into your database - Upload and serve static files using [Storage](/docs/guides/storage)