new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Next.js App Router · all subjects

server actions & authentication

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Server Action definition

A Server Action is a Server Function that is passed to a Client Component as a prop or bound to a form action. Server Actions are commonly used for form submissions and data mutations.

Server Function definition and invocation

A Server Function is an asynchronous function that runs on the server, marked with the 'use server' directive. Server Functions can be invoked from Client Components. When passed as a prop to a Client Component or bound to a form action, they are called Server Actions.

'use server' directive syntax and scope

The 'use server' directive marks a function as a Server Function that can be called from client-side code. It can be placed at the top of a file to indicate that all exports in the file are Server Functions, or inline at the top of a function to mark that specific function.

updateTag(tag) makes Server Action update immediately visible

Use `updateTag(tag)` when a Server Action must make its update visible immediately. The next server read waits for fresh data.

revalidateTag(tag, 'max') for passive updates or acceptable stale data

Use `revalidateTag(tag, 'max')` when the update is passive or stale data is acceptable. The next server read serves stale data while revalidating in the background.

revalidateTag(tag, { expire: 0 }) for immediate expiration by webhook or external system

Use `revalidateTag(tag, { expire: 0 })` when a webhook or external system requires immediate expiration. The next server read waits for fresh data.

Server Action updateTag example

Example: markActivityReadAction Server Action calls updateTag(activityCache.tag(userId)) after writing to database. This invalidates the tagged server cache so the next read returns fresh data.

Coordinate mutations with updateTag in Server Action

In a Server Action, call updateTag with the cached server tag to expire the tagged server data after the mutation. This ensures the next cached server read returns fresh data. Keep updateTag in the same action that changes the cached read that must reflect the write immediately.

Give your agent this brain