Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions app/_examples/client-component/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
'use client'
"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'
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { useEffect, useState } from "react";

export default function ClientComponent() {
const [todos, setTodos] = useState<any[]>([])
const [todos, setTodos] = useState<any[]>([]);

// Create a Supabase client configured to use cookies
const supabase = createClientComponentClient()
const supabase = createClientComponentClient();

useEffect(() => {
const getTodos = async () => {
// This assumes you have a `todos` table in Supabase. Check out
// the `Create Table and seed with data` section of the README 👇
// https://github.com/vercel/next.js/blob/canary/examples/with-supabase/README.md
const { data } = await supabase.from('todos').select()
const { data } = await supabase.from("todos").select();
if (data) {
setTodos(data)
setTodos(data);
}
}
};

getTodos()
}, [supabase, setTodos])
getTodos();
}, [supabase, setTodos]);

return <pre>{JSON.stringify(todos, null, 2)}</pre>
return <pre>{JSON.stringify(todos, null, 2)}</pre>;
}
20 changes: 10 additions & 10 deletions app/_examples/server-action/page.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
// 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'
import { createServerActionClient } from "@supabase/auth-helpers-nextjs";
import { revalidatePath } from "next/cache";
import { cookies } from "next/headers";

export default async function ServerAction() {
const addTodo = async (formData: FormData) => {
'use server'
const title = formData.get('title')
"use server";
const title = formData.get("title");

if (title) {
// Create a Supabase client configured to use cookies
const supabase = createServerActionClient({ cookies })
const supabase = createServerActionClient({ cookies });

// This assumes you have a `todos` table in Supabase. Check out
// the `Create Table and seed with data` section of the README 👇
// https://github.com/vercel/next.js/blob/canary/examples/with-supabase/README.md
await supabase.from('todos').insert({ title })
revalidatePath('/server-action-example')
await supabase.from("todos").insert({ title });
revalidatePath("/server-action-example");
}
}
};

return (
<form action={addTodo}>
<input name="title" />
</form>
)
);
}
7 changes: 3 additions & 4 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export default function RootLayout({
</div>
<TailwindIndicator />
</ThemeProvider>
</body>
</html>
);
}
</body>
</html>
);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweep: regenerate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

1 change: 0 additions & 1 deletion components/site-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export async function SiteHeader() {
<span className="sr-only">GitHub</span>
</div>
</Link>
<ThemeToggle />
{user && <UserNav user={user} />}
</nav>
</div>
Expand Down
23 changes: 0 additions & 23 deletions components/theme-toggle.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +0,0 @@
"use client";

import * as React from "react";
import { useTheme } from "next-themes";

import { Button } from "@/components/ui/button";
import { Icons } from "@/components/icons";

export function ThemeToggle() {
const { setTheme, theme } = useTheme();

return (
<Button
variant="ghost"
size="sm"
onClick={() => setTheme(theme === "light" ? "dark" : "light")}
>
<Icons.sun className="rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Icons.moon className="absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
);
}