Untitled
Anonymous
Plain Text
09/07/2025 12:08 PM
362 B
17
Indexable
Never
// Server Component
import { getCount, setCount } from '@/db';
export default async function Page() {
const count = await getCount();
async function inc() { 'use server'; await setCount(count + 1); }
return (
<form action={async () => { await inc(); /* client: router.refresh() */ }}>
<p>{count}</p>
<button>+1</button>
</form>
);
}
Editor is loading...
Leave a Comment