Edit

provideTelefuncContext()

Environment: server.

provideTelefuncContext() makes the context object available to telefunctions (via getContext()) — useful when a telefunction runs outside telefunc.serve(), such as server-side rendering or unit tests.

// Environment: server
 
import { provideTelefuncContext } from 'telefunc'
 
provideTelefuncContext({ user })
// getContext() inside telefunctions now returns { user }

Call it before the telefunction runs (e.g. in your test setup or your SSR request handler).

With serve() / new Telefunc(), the context is provided for you — see API > getContext() > Provide. Reach for provideTelefuncContext() only when a telefunction runs outside both.

See also