"use client"; import { useConvexAuth, useMutation, useQuery } from "convex/react"; import { api } from "../convex/_generated/api"; import Link from "next/link"; import { useAuthActions } from "@convex-dev/auth/react"; import { useRouter } from "next/navigation"; export default function Home() { return ( <>
Convex + Next.js + Convex Auth

Convex + Next.js + Convex Auth

); } function SignOutButton() { const { isAuthenticated } = useConvexAuth(); const { signOut } = useAuthActions(); const router = useRouter(); return ( <> {isAuthenticated && ( )} ); } function Content() { const { viewer, numbers } = useQuery(api.myFunctions.listNumbers, { count: 10, }) ?? {}; const addNumber = useMutation(api.myFunctions.addNumber); if (viewer === undefined || numbers === undefined) { return (

loading... (consider a loading skeleton)

); } return (

Welcome {viewer ?? "Anonymous"}!

Click the button below and open this page in another window - this data is persisted in the Convex cloud database!

Numbers:{" "} {numbers?.length === 0 ? "Click the button!" : (numbers?.join(", ") ?? "...")}

Edit{" "} convex/myFunctions.ts {" "} to change your backend

Edit{" "} app/page.tsx {" "} to change your frontend

See the{" "} /server route {" "} for an example of loading data in a server component

Useful resources:

); } function ResourceCard({ title, description, href, }: { title: string; description: string; href: string; }) { return (
{title}

{description}

); }