Complete the code to define a server action that updates data.
"use server"; export const updateData = async () => { await [1](); }
The revalidatePath function triggers Next.js to refresh the data on the server, simplifying mutations by avoiding manual cache updates.
Complete the code to mark a function as a server action in Next.js.
"use server"; export async function [1]() { // mutation logic }
Server actions must be marked with "use server" and have a proper name indicating their purpose, like serverAction.
Fix the error in the server action call to ensure mutation triggers revalidation.
"use server"; async function handleSubmit() { await [1](); // missing revalidation }
After mutation, calling revalidatePath ensures the server updates the cached data, simplifying state management.
Fill both blanks to create a server action that updates data and triggers revalidation.
"use server"; export async function updateItem() { await [1](); [2]('/items'); }
The server action calls updateDatabase to mutate data, then revalidatePath to refresh the cache for the '/items' path.
Fill all three blanks to define a server action that updates, revalidates, and logs success.
"use server"; export async function saveData() { await [1](); [2]('/dashboard'); [3]('Update complete'); }
The server action updates the record, triggers revalidation for '/dashboard', and logs a success message.