The awaitResult(deferFn) transforms your function into an asynchronous call, waiting for it to be executed on the Defer Platform. You can get its result like you normally do with an async function.


import { defer } from "@defer/client";

// print "hello {name}" after 5s wait
const sayHello = (name: string) =>
  new Promise((resolve) => setTimeout(() => resolve(`Hello ${name}!`), 5000));

export default defer(sayHello);