"use client"; import { useAuth } from "@farm.js/auth/client"; import { useEffect } from "react"; import { SignOutButton } from "../../components/sign-out-button"; import { SiteHeader } from "../../components/site-header"; export default function DashboardPage() { const { isPending, session, user } = useAuth(); useEffect(() => { if (!isPending && !user) { window.location.replace("/sign-in"); } }, [isPending, user]); if (isPending) { return (
Verifying protected session
); } if (!user || !session) { return (
Session unavailable

Returning you to the sign-in page…

); } const createdAt = new Date(user.createdAt).toLocaleDateString("en", { day: "numeric", month: "short", year: "numeric", }); const expiresAt = new Date(session.expiresAt).toLocaleString("en", { day: "numeric", hour: "2-digit", minute: "2-digit", month: "short", }); return (
PROTECTED / MIDDLEWARE VERIFIED

Welcome back, {user.name}.

Farm route middleware verified your session before this dashboard loaded.

Account
Name
{user.name}
Email
{user.email}
Created
{createdAt}
Current session httpOnly cookie
Session ID
{session.id}
Expires
{expiresAt}
Storage
SQLite locally / Postgres in production
NEXT / MAKE IT YOURS

The account boundary is ready for product work.

01

Set the production FARMJS Auth URL, secret, and database URL in your host.

02

Run the FARMJS Auth migration command before serving production traffic.

03

Build your first protected feature beside this dashboard route.

); }