[API reference](https://evolu.dev/docs/api-reference) › [@evolu/sqlite-wasm](https://evolu.dev/docs/api-reference/sqlite-wasm) › [c-api](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api) › sqlite3\_create\_function\_v2

```ts
function sqlite3_create_function_v2(
  deps: SqliteWasmDep,
): (
  db: SqliteDbPtr,
  zFunctionName: CStringPtr,
  nArg: number,
  eTextRep: number,
  pApp: 0 | WasmPtr,
  xFunc: 0 | SqliteFunctionPtr,
  xStep: 0 | SqliteFunctionPtr,
  xFinal: 0 | SqliteFunctionPtr,
  xDestroy: 0 | SqliteFunctionPtr,
) => SqliteResultCode;
```

Defined in: [packages/sqlite-wasm/src/CApi.ts:2587](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/sqlite-wasm/src/CApi.ts#L2587)

Works like [sqlite3\_create\_function](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api/functions/sqlite3_create_function), and SQLite calls a non-NULL
xDestroy with pApp when the function is redefined or removed, when the
connection closes, and when this call fails.

Wasm type `i(iiiiiiiii)`. Signature `["sqlite3_create_function_v2", "int",
"sqlite3*", "string", "int", "int", "*", "funcptr:v(pip)", "funcptr:v(pip)",
"funcptr:v(p)", "funcptr:v(p)"]` from Evolu's supplement: SQLite binds it by
hand to accept JavaScript functions as callbacks.

See https://sqlite.org/c3ref/create_function.html.