</form>
  )
}
On-demand Revalidation
Server Actions can be used to revalidate data on-demand by path (revalidatePath) or by cache tag (revalidateTag).
 import { revalidateTag } from 'next/cache'
 
async function revalidate() {
  'use server'
  revalidateTag('blog-posts')
}
Validation
The data passed to a Server Action can be validated or sanitized before invoking the action. For example, you can create a wrapper function that receives the action as its argument, and returns a function that invokes the action if it's valid.
app/actions.js 'use server'
 
import { withValidate } from 'lib/form-validation'
 
export const action = withValidate((data) => {
  // ...
})
lib/form-validation.js export function withValidate(action) {
  return async (formData) => {
    'use server'