Unverified Commit 0674d95d authored by Jon Meyers's avatar Jon Meyers Committed by GitHub

examples: improve `with-supabase` example (#51442)

parent 77ef61ea
......@@ -11,32 +11,30 @@ The Vercel deployment will guide you through creating a Supabase account and pro
## How to use
1. Create a [new Supabase project](https://database.new)
1. Run `npx create-next-app -e with-supabase myapp` to create a Next.js app using the Supabase Starter template
1. Run `cd myapp` to change into the app's directory
1. Run `npx create-next-app -e with-supabase` to create a Next.js app using the Supabase Starter template
1. Use `cd` to change into the app's directory
1. Run `npm install` to install dependencies
1. Rename `.env.local.example` to `.env.local` and update the values for `NEXT_PUBLIC_SUPABASE_URL` and `NEXT_PUBLIC_SUPABASE_ANON_KEY` from [your Supabase project's API settings](https://app.supabase.com/project/_/settings/api)
1. Run `npm run dev` to start the local development server
> Check out [the docs for Local Development](https://supabase.com/docs/guides/getting-started/local-development) to also run Supabase locally.
### Create Table and seed with data (optional)
### Create a Supabase client
Navigate to [your project's SQL Editor](https://app.supabase.com/project/_/sql), click `New query`, paste the following SQL 👇 and click `RUN`.
Check out the [`/app/_examples`](./app/_examples/) folder for an example of creating a Supabase client in:
```sql
create table if not exists todos (
id uuid default gen_random_uuid() primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
title text,
is_complete boolean default false
);
- [Client Components](./app/_examples/client-component/page.tsx)
- [Server Components](./app/_examples/server-component/page.tsx)
- [Route Handlers](./app/_examples/route-handler/route.ts)
- [Server Actions](./app/_examples/server-action/page.tsx)
insert into todos(title)
values
('Create Supabase project'),
('Create Next.js app from Supabase Starter template'),
('Keeping building cool stuff!');
```
### Create `todo` table and seed with data (optional)
Navigate to [your project's SQL Editor](https://app.supabase.com/project/_/sql), click `New query`, paste the contents of the [init.sql](./supabase/migrations/20230618024722_init.sql) file and click `RUN`.
This will create a basic `todos` table, enable Row Level Security (RLS), and write RLS policies enabling `select` and `insert` actions for `authenticated` users.
To seed your `todos` table with some dummy data, run the contents of the [seed.sql](./supabase/seed.sql) file.
## Feedback and issues
......
'use client'
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'
import { useEffect, useState } from 'react'
......
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
import {
createServerActionClient,
createServerComponentClient,
} from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import Image from 'next/image'
import { redirect } from 'next/navigation'
export default async function ProtectedRoute() {
const supabase = createServerComponentClient({ cookies })
const {
data: { user },
} = await supabase.auth.getUser()
if (!user) {
// This route can only be accessed by authenticated users.
// Unauthenticated users will be redirected to the `/login` route.
redirect('/login')
}
const signOut = async () => {
'use server'
const supabase = createServerActionClient({ cookies })
await supabase.auth.signOut()
redirect('/login')
}
return (
<div className="flex-1 flex flex-col max-w-3xl mt-24">
<h1 className="text-2xl mb-2 flex justify-between">
<span className="sr-only">Supabase and Next.js Starter Template</span>
</h1>
<div className="flex border-b py-3 text-sm text-neutral-100">
<div className="flex items-center justify-between w-full">
<code className="bg-neutral-700 px-3 py-1 rounded-lg text-sm">
Protected page
</code>
<span className="flex gap-4">
Hey, {user.email}! <span className="border-r"></span>{' '}
<form action={signOut}>
<button className="text-neutral-100">Logout</button>
</form>
</span>
</div>
</div>
<div className="flex gap-8 justify-center mt-12">
<Image
src="/supabase.svg"
alt="Supabase Logo"
width={225}
height={45}
priority
/>
<div className="border-l rotate-45 h-10"></div>
<Image
src="/next.svg"
alt="Vercel Logo"
width={150}
height={36}
priority
/>
</div>
<p className="text-3xl mx-auto max-w-2xl text-center mt-8 text-white">
The fastest way to get started building apps with{' '}
<strong>Supabase</strong> and <strong>Next.js</strong>
</p>
<div className="flex justify-center mt-12">
<span className="bg-neutral-100 py-3 px-6 rounded-lg font-mono text-sm text-neutral-900">
Get started by editing <strong>app/page.tsx</strong>
</span>
</div>
</div>
)
}
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import { NextResponse } from 'next/server'
......
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
import { createServerActionClient } from '@supabase/auth-helpers-nextjs'
import { revalidatePath } from 'next/cache'
import { cookies } from 'next/headers'
......
// TODO: Duplicate or move this file outside the `_examples` folder to make it a route
import { createServerComponentClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
......
......@@ -13,7 +13,7 @@ export default function RootLayout({
return (
<html lang="en">
<body>
<main className="min-h-screen bg-gray-900 flex flex-col items-center">
<main className="min-h-screen bg-neutral-900 flex flex-col items-center">
{children}
</main>
</body>
......
......@@ -25,18 +25,17 @@ export default function Login() {
const handleSignIn = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault()
const { data, error } = await supabase.auth.signInWithPassword({
await supabase.auth.signInWithPassword({
email,
password,
})
console.log({ data, error })
router.push('/')
}
return (
<div className="flex-1 flex flex-col w-full max-w-sm justify-center gap-2">
{view === 'check-email' ? (
<p className="text-center text-gray-400">
<p className="text-center text-neutral-400">
Check <span className="font-bold text-white">{email}</span> to
continue signing up
</p>
......@@ -45,21 +44,21 @@ export default function Login() {
className="flex-1 flex flex-col w-full max-w-sm justify-center gap-2"
onSubmit={view === 'sign-in' ? handleSignIn : handleSignUp}
>
<label className="text-md text-gray-400" htmlFor="email">
<label className="text-md text-neutral-400" htmlFor="email">
Email
</label>
<input
className="rounded-md px-4 py-2 bg-inherit border mb-6"
className="rounded-md px-4 py-2 bg-inherit border mb-6 text-neutral-100"
name="email"
onChange={(e) => setEmail(e.target.value)}
value={email}
placeholder="you@example.com"
/>
<label className="text-md text-gray-400" htmlFor="password">
<label className="text-md text-neutral-400" htmlFor="password">
Password
</label>
<input
className="rounded-md px-4 py-2 bg-inherit border mb-6"
className="rounded-md px-4 py-2 bg-inherit border mb-6 text-neutral-100"
type="password"
name="password"
onChange={(e) => setPassword(e.target.value)}
......@@ -68,10 +67,10 @@ export default function Login() {
/>
{view === 'sign-in' ? (
<>
<button className="bg-green-700 rounded px-4 py-2 text-gray-200 mb-6">
<button className="bg-green-700 rounded px-4 py-2 text-neutral-200 mb-6">
Sign In
</button>
<p className="text-sm text-gray-500 text-center">
<p className="text-sm text-neutral-500 text-center">
Don't have an account?
<button
className="ml-1 text-white underline"
......@@ -84,10 +83,10 @@ export default function Login() {
) : null}
{view === 'sign-up' ? (
<>
<button className="bg-green-700 rounded px-4 py-2 text-gray-200 mb-6">
<button className="bg-green-700 rounded px-4 py-2 text-neutral-200 mb-6">
Sign Up
</button>
<p className="text-sm text-gray-500 text-center">
<p className="text-sm text-neutral-500 text-center">
Already have an account?
<button
className="ml-1 text-white underline"
......
'use client'
import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'
import { useRouter } from 'next/navigation'
export default function LogoutButton() {
const router = useRouter()
// Create a Supabase client configured to use cookies
const supabase = createClientComponentClient()
const signOut = async () => {
await supabase.auth.signOut()
router.push('/login')
}
return (
<button className="hover:underline" onClick={signOut}>
Logout
</button>
)
}
import {
createServerActionClient,
createServerComponentClient,
} from '@supabase/auth-helpers-nextjs'
import { createServerComponentClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import { redirect } from 'next/navigation'
import Image from 'next/image'
import Link from 'next/link'
import LogoutButton from './logout-button'
const resources = [
{
......@@ -11,21 +10,33 @@ const resources = [
subtitle:
'This free course by Jon Meyers, shows you how to configure Supabase Auth to use cookies, and steps through some common patterns.',
url: 'https://youtube.com/playlist?list=PL5S4mPUpp4OtMhpnp93EFSo42iQ40XjbF',
},
{
title: 'Supabase Auth Helpers Docs',
subtitle:
'This template has configured Supabase Auth to use cookies for you, but the docs are a great place to learn more.',
url: 'https://supabase.com/docs/guides/auth/auth-helpers/nextjs',
icon: 'youtube',
},
{
title: 'Supabase Next.js App Router Example',
subtitle:
'Want to see a code example containing some common patterns with Next.js and Supabase? Check out this repo!',
url: 'https://github.com/supabase/supabase/tree/master/examples/auth/nextjs',
icon: 'code',
},
{
title: 'Supabase Auth Helpers Docs',
subtitle:
'This template has configured Supabase Auth to use cookies for you, but the docs are a great place to learn more.',
url: 'https://supabase.com/docs/guides/auth/auth-helpers/nextjs',
icon: 'book',
},
]
const examples = [
{ type: 'Client Components', src: 'app/_examples/client-component/page.tsx' },
{ type: 'Server Components', src: 'app/_examples/server-component/page.tsx' },
{ type: 'Server Actions', src: 'app/_examples/server-action/page.tsx' },
{ type: 'Route Handlers', src: 'app/_examples/route-handler.ts' },
{ type: 'Middleware', src: 'app/middleware.ts' },
{ type: 'Protected Routes', src: 'app/_examples/protected/page.tsx' },
]
export default async function Index() {
const supabase = createServerComponentClient({ cookies })
......@@ -33,61 +44,107 @@ export default async function Index() {
data: { user },
} = await supabase.auth.getUser()
// This is a Protected Route that can only be accessed by authenticated users
// users who are not signed in will be redirected to the `/login` route
if (!user) {
redirect('/login')
}
const signOut = async () => {
'use server'
const supabase = createServerActionClient({ cookies })
await supabase.auth.signOut()
redirect('/login')
}
return (
<div className="flex-1 flex flex-col max-w-3xl mt-72">
<div className="flex-1 flex flex-col max-w-3xl mt-24">
<h1 className="text-2xl mb-2 flex justify-between">
Hey, {user.email}
<form action={signOut} className="inline ml-2">
<button className="text-sm text-gray-400">Logout</button>
</form>
<span className="sr-only">Supabase and Next.js Starter Template</span>
</h1>
<hr />
<div className="flex border-b py-3 text-sm text-neutral-100">
<span className="ml-auto">
{user ? (
<span className="flex gap-4">
Hey, {user.email}! <span className="border-r"></span>{' '}
<LogoutButton />
</span>
) : (
<Link href="/login" className="text-neutral-100 hover:underline">
Login
</Link>
)}
</span>
</div>
<div className="flex gap-8 justify-center mt-12">
<Image
src="/supabase.svg"
alt="Supabase Logo"
width={225}
height={45}
priority
/>
<div className="border-l rotate-45 h-10"></div>
<Image
src="/next.svg"
alt="Vercel Logo"
width={150}
height={36}
priority
/>
</div>
<p className="text-3xl mx-auto max-w-2xl text-center mt-8 text-white">
The fastest way to get started building apps with{' '}
<strong>Supabase</strong> and <strong>Next.js</strong>
</p>
<div className="flex justify-center mt-16">
<span className="bg-neutral-100 py-3 px-6 rounded-lg font-mono text-sm text-neutral-900">
Get started by editing <strong>app/page.tsx</strong>
</span>
</div>
<p className="text-gray-300 mt-16 mb-16">
Here are some helpful resources to get you started! 👇
<p className="text-neutral-100 mt-28 text-lg font-bold text-center">
Everything you need to started
</p>
<div className="flex gap-4 h-60 mb-16">
{resources.map(({ title, subtitle, url }) => (
<div className="flex gap-12 h-60 mt-10 mb-16 -mx-12">
{resources.map(({ title, subtitle, url, icon }) => (
<a
className="flex-1 border border-gray-400 rounded-md p-6 hover:bg-gray-800"
key={title}
className="grid gap-4 border-t-2 border-neutral-200 py-6 pr-2 group text-neutral-100"
href={url}
>
<h2 className="font-bold mb-2">{title}</h2>
<p className="text-sm text-gray-400">{subtitle}</p>
<h2 className="font-bold mb-2 group-hover:underline min-h-[42px]">
{title}
</h2>
<p className="text-sm text-neutral-100">{subtitle}</p>
<div className="mt-2">
<Image
src={`/${icon}.svg`}
alt="Vercel Logo"
width={20}
height={25}
priority
/>
</div>
</a>
))}
</div>
<p className="text-gray-300 mb-16">
Ready to build your app? Head over to `app/page.tsx` 👉
</p>
<div className="bg-gray-800 rounded-md p-8 text-gray-300">
<p className="font-semibold mb-2 text-gray-200">
We have also included examples for creating a Supabase client in:
<div className="grid gap-3 justify-center mx-auto max-w-lg text-center mt-16">
<p className="text-neutral-100 text-lg font-bold text-center">
Examples
</p>
<p className="mb-2 text-white">
Look in the <code>_examples</code> folder to see how to create a
Supabase client in all the different contexts
</p>
<ul className="list-disc ml-8">
<li>Client Components - `app/client-component-example/page.tsx`</li>
<li>Server Components - `app/server-component-example/page.tsx`</li>
<li>Server Actions - `app/server-action-example/page.tsx`</li>
<li>Route Handlers - `app/route-handler-example/route.ts`</li>
<li>Middleware - `middleware.ts`</li>
</ul>
</div>
<div className=" text-white mb-24 grid justify-center border-t mt-8">
{examples.map(({ type, src }) => (
<div className="" key={type}>
<div className="grid grid-cols-2 gap-4 border-b">
<span className="font-bold text-right border-r pr-4 py-4">
{type}{' '}
</span>
<span className="py-4">
<code className="text-sm">{src}</code>
</span>
</div>
</div>
))}
</div>
</div>
)
......
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f5f5f5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-book-open"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f5f5f5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-code"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#f5f5f5" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#f5f5f5" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="310" height="60" fill="none" viewBox="0 0 311 60"><path fill="#f5f5f5" d="M80.923 35.67c.321 3.002 3.053 8.15 10.978 8.15 6.908 0 10.229-4.397 10.229-8.686 0-3.86-2.624-7.024-7.819-8.096l-3.749-.805c-1.445-.268-2.41-1.072-2.41-2.359 0-1.501 1.5-2.627 3.374-2.627 3 0 4.124 1.984 4.338 3.539l5.944-1.34c-.321-2.842-2.838-7.614-10.335-7.614-5.677 0-9.854 3.914-9.854 8.632 0 3.7 2.303 6.756 7.39 7.882l3.481.804c2.035.429 2.839 1.394 2.839 2.573 0 1.394-1.125 2.627-3.481 2.627-3.106 0-4.66-1.93-4.82-4.02l-6.105 1.34ZM124.891 43.016h6.801a43.452 43.452 0 0 1-.268-4.772V16.637h-7.123V31.97c0 3.056-1.82 5.2-4.98 5.2-3.32 0-4.82-2.359-4.82-5.308V16.637h-7.122V33.31c0 5.737 3.641 10.401 10.014 10.401 2.785 0 5.838-1.072 7.284-3.538 0 1.072.107 2.305.214 2.842ZM146.146 53.206v-12.76c1.285 1.77 3.963 3.217 7.605 3.217 7.443 0 12.423-5.898 12.423-13.887 0-7.828-4.444-13.725-12.155-13.725-3.963 0-6.909 1.769-8.087 3.807V16.64h-6.908v36.566h7.122Zm13.013-23.376c0 4.718-2.891 7.453-6.533 7.453-3.641 0-6.587-2.788-6.587-7.453 0-4.665 2.946-7.399 6.587-7.399 3.642 0 6.533 2.734 6.533 7.399ZM170.21 35.83c0 4.129 3.427 7.936 9.05 7.936 3.909 0 6.426-1.823 7.765-3.914 0 1.018.107 2.466.267 3.163h6.534c-.161-.911-.321-2.788-.321-4.182V25.858c0-5.308-3.106-10.026-11.46-10.026-7.069 0-10.872 4.557-11.299 8.686l6.318 1.34c.215-2.305 1.928-4.29 5.034-4.29 2.999 0 4.445 1.556 4.445 3.432 0 .912-.482 1.662-1.981 1.877l-6.48.965c-4.391.643-7.872 3.27-7.872 7.989Zm10.549 2.628c-2.302 0-3.427-1.502-3.427-3.056 0-2.038 1.446-3.056 3.267-3.325l5.944-.911v1.18c0 4.664-2.785 6.112-5.784 6.112ZM207.591 43.017V39.8c1.392 2.252 4.177 3.86 7.819 3.86 7.497 0 12.424-5.951 12.424-13.94 0-7.828-4.445-13.779-12.157-13.779-3.909 0-6.801 1.716-7.979 3.592V4.2h-7.015v38.818h6.908Zm13.12-13.243c0 4.825-2.891 7.506-6.533 7.506-3.588 0-6.587-2.734-6.587-7.506 0-4.826 2.999-7.453 6.587-7.453 3.642 0 6.533 2.627 6.533 7.453ZM231.864 35.83c0 4.129 3.427 7.936 9.051 7.936 3.908 0 6.426-1.823 7.764-3.914 0 1.018.108 2.466.268 3.163h6.533c-.16-.911-.321-2.788-.321-4.182V25.858c0-5.308-3.106-10.026-11.46-10.026-7.069 0-10.871 4.557-11.299 8.686l6.318 1.34c.215-2.305 1.929-4.29 5.034-4.29 3 0 4.445 1.556 4.445 3.432 0 .912-.481 1.662-1.981 1.877l-6.479.965c-4.392.643-7.873 3.27-7.873 7.989Zm10.55 2.628c-2.303 0-3.428-1.502-3.428-3.056 0-2.038 1.446-3.056 3.267-3.325l5.944-.911v1.18c0 4.664-2.784 6.112-5.783 6.112ZM260.087 35.67c.321 3.002 3.053 8.15 10.978 8.15 6.908 0 10.228-4.397 10.228-8.686 0-3.86-2.623-7.024-7.818-8.096l-3.749-.805c-1.446-.268-2.409-1.072-2.409-2.359 0-1.501 1.499-2.627 3.373-2.627 3 0 4.124 1.984 4.339 3.539l5.944-1.34c-.322-2.842-2.839-7.614-10.336-7.614-5.677 0-9.853 3.914-9.853 8.632 0 3.7 2.302 6.756 7.39 7.882l3.481.804c2.035.429 2.838 1.394 2.838 2.573 0 1.394-1.125 2.627-3.481 2.627-3.106 0-4.659-1.93-4.82-4.02l-6.105 1.34ZM292.112 26.823c.16-2.413 2.196-5.2 5.891-5.2 4.069 0 5.784 2.573 5.891 5.2h-11.782Zm12.478 6.863c-.857 2.359-2.678 4.021-5.998 4.021-3.535 0-6.48-2.52-6.64-6.005h18.85c0-.107.107-1.18.107-2.198 0-8.471-4.873-13.672-13.013-13.672-6.748 0-12.96 5.469-12.96 13.886 0 8.9 6.372 14.101 13.602 14.101 6.48 0 10.657-3.806 11.996-8.364l-5.944-1.769Z"/><path fill="url(#a)" d="M34.137 59.003c-1.533 1.93-4.64.873-4.678-1.592l-.54-36.049h24.24c4.39 0 6.839 5.07 4.109 8.51L34.137 59.002Z"/><path fill="url(#b)" fill-opacity=".2" d="M34.137 59.003c-1.533 1.93-4.64.873-4.678-1.592l-.54-36.049h24.24c4.39 0 6.839 5.07 4.109 8.51L34.137 59.002Z"/><path fill="#3ECF8E" d="M24.278.997c1.533-1.93 4.641-.873 4.678 1.592l.237 36.049H5.257c-4.39 0-6.84-5.07-4.11-8.51L24.279.998Z"/><defs><linearGradient id="a" x1="28.919" x2="50.462" y1="29.355" y2="38.39" gradientUnits="userSpaceOnUse"><stop stop-color="#249361"/><stop offset="1" stop-color="#3ECF8E"/></linearGradient><linearGradient id="b" x1="19.368" x2="29.193" y1="16.278" y2="34.773" gradientUnits="userSpaceOnUse"><stop/><stop offset="1" stop-opacity="0"/></linearGradient></defs></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#f5f5f5" strokeWidth="2" strokeLinecap="round" strokeLineJoin="round" class="lucide lucide-youtube"><path d="M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17"/><path d="m10 15 5-3-5-3z"/></svg>
\ No newline at end of file
create table if not exists todos (
id uuid default gen_random_uuid() primary key,
created_at timestamp with time zone default timezone('utc'::text, now()) not null,
title text,
is_complete boolean default false,
user_id uuid references auth.users default auth.uid()
);
-- Set up Row Level Security (RLS)
-- See https://supabase.com/docs/guides/auth/row-level-security for more details.
alter table todos
enable row level security;
create policy "Authenticated users can select todos" on todos
for select to authenticated using (true);
create policy "Authenticated users can insert their own todos" on todos
for insert to authenticated with check (auth.uid() = user_id);
insert into todos(title)
values
('Create Supabase project'),
('Create Next.js app from Supabase Starter template'),
('Keep building cool stuff!');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment