Good to know: Using startTransition disables the out-of-the-box Progressive Enhancement.
app/components/example-client-component.js 'use client'
 
import { useTransition } from 'react'
import { addItem } from '../actions'
 
function ExampleClientComponent({ id }) {
  let [isPending, startTransition] = useTransition()
 
  return (
    <button onClick={() => startTransition(() => addItem(id))}>
      Add To Cart
    </button>
  )
}
app/actions.js 'use server'
 
export async function addItem(id) {
  await addItemToDb(id)
  // Marks all product pages for revalidating
  revalidatePath('/product/[id]')
}
Custom invocation without startTransition
If you aren't doing Server Mutations, you can directly pass the function as a prop like any other function.