return async (formData) => {
    'use server'
 
    const isValidData = verifyData(formData)
 
    if (!isValidData) {
      throw new Error('Invalid input.')
    }
 
    const data = process(formData)
    return action(data)
  }
}
Using headers
You can read incoming request headers such as cookies and headers within a Server Action.
 import { cookies } from 'next/headers'
 
async function addItem(data) {
  'use server'
 
  const cartId = cookies().get('cartId')?.value
 
  await saveToDb({ cartId, data })
}
Additionally, you can modify cookies within a Server Action.
 import { cookies } from 'next/headers';
 
async function create(data) {
  'use server';
 
  const cart = await createCart():