[API reference](https://evolu.dev/docs/api-reference) › @evolu/sqlite-wasm

## Modules

| Module                                                  | Description                                                                                                   |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| [c-api](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api) | SQLite's C API as the wasm exports it: the C-named functions, the SQLITE_* constants, and the struct layouts. |

## Interfaces

| Interface                                                                                                               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [OpfsDirectoryHandle](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/OpfsDirectoryHandle)                               | The part of `FileSystemDirectoryHandle` the pool uses.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [OpfsFileHandle](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/OpfsFileHandle)                                         | The part of `FileSystemFileHandle` the pool uses.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| [OpfsNameError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/OpfsNameError)                                           | Error returned when a string is not a valid [OpfsName](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/OpfsName).                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [OpfsRoot](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/OpfsRoot)                                                     | Access to the OPFS root, which `navigator.storage` provides in a dedicated worker.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [OpfsRootDep](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/OpfsRootDep)                                               | Dependency wrapper for [OpfsRoot](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/OpfsRoot).                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [OpfsSyncAccessHandle](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/OpfsSyncAccessHandle)                             | The part of `FileSystemSyncAccessHandle` the pool uses.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [SahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool)                                                       | A pool of sync access handles, and the VFS SQLite opens its files with, on which File and EncryptedFile databases open.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [SahPoolAlreadyOpenError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPoolAlreadyOpenError)                       | This instance has a pool in the directory open, or is opening one. A retry succeeds once that pool is disposed or its open failed.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [SahPoolFileNotFoundError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPoolFileNotFoundError)                     | The pool has no file with the path.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [SahPoolFullError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPoolFullError)                                     | No slot of the pool is free for a new file, which `xOpen` records when it fails with SQLITE_CANTOPEN.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [SahPoolHeldError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPoolHeldError)                                     | Another context or instance holds a slot of the pool. The pool wrote nothing, and a retry succeeds once the slot is released.                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [SahPoolInvalidPathError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPoolInvalidPathError)                       | A name `xOpen`, `xDelete` or `xAccess` cannot map to a pool path, because the suffix SQLite appends would land in its query, fragment or host, which would map a database and its journal to the same file. `xOpen` also records it for a path that would not fit a slot's header, or a database's path whose super-journal's path would not.                                                                                                                                                                                                                         |
| [SahPoolOptions](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPoolOptions)                                         | Options for [openSahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/openSahPool).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [SahPoolSetupError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPoolSetupError)                                   | OPFS failed while the pool was being set up, or its VFS could not be registered.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| [SqliteCodecFailure](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteCodecFailure)                                 | The first failure Evolu's codec recorded for the main database of a File or EncryptedFile connection since the top-level operation started. It has no method or path, because the codec records a failure of the database's journal on the database.                                                                                                                                                                                                                                                                                                                  |
| [SqliteDatabase](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteDatabase)                                         | An open SQLite database. Disposing it while one of its operations runs, as from a callback, throws.                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [SqliteEmptySqlError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteEmptySqlError)                               | The SQL contains no statement, only whitespace or comments.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [SqliteEncryptedDatabase](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteEncryptedDatabase)                       | The result of [createEncryptedSqliteDatabase](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/createEncryptedSqliteDatabase).                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [SqliteEncryptedFileDatabaseOptions](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteEncryptedFileDatabaseOptions) | A database file on a [SahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool) that Evolu's codec encrypts, in the format of SQLite3 Multiple Ciphers' `sqlcipher` scheme.                                                                                                                                                                                                                                                                                                                                                                                    |
| [SqliteEncryptionUnsupportedError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteEncryptionUnsupportedError)     | What Evolu's codec refuses because it cannot keep a database encrypted, or because a database keyed through SQL would stay plaintext. For an encrypted database, a read or write that is not a whole page, a page 1 that would change the page size or the reserved bytes, as a VACUUM that changes the page size writes it, turning `secure_delete` off, or the hot journal of one opened without its key, which fails with SQLITE_CANTOPEN and stays for the key. For any database on a pool, the keying pragmas, such as `PRAGMA key`, and a page 1 that says WAL. |
| [SqliteError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteError)                                               | An error SQLite reported.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [SqliteFileDatabaseOptions](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteFileDatabaseOptions)                   | An unencrypted database file on a [SahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool).                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [SqliteInvalidSqlTextError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteInvalidSqlTextError)                   | The SQL is text SQLite would read as other SQL, so it fails before SQLite sees it: it contains a NUL character, which SQLite reads SQL only up to, so it would silently ignore the rest, or a lone surrogate, which UTF-8 cannot encode, so it would run with U+FFFD in its place.                                                                                                                                                                                                                                                                                    |
| [SqliteMemoryDatabaseOptions](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteMemoryDatabaseOptions)               | An in-memory database on the default VFS, which never touches OPFS. Temporary tables and indexes stay in memory in every mode.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [SqliteMultipleStatementsError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteMultipleStatementsError)           | The SQL contains more than one statement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [SqliteNoMemError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteNoMemError)                                     | `sqlite3_malloc` returned NULL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [SqlitePageAuthenticationError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqlitePageAuthenticationError)           | A page of an encrypted database or its journal that failed to authenticate, because the key is wrong or the page was altered or cut short, as Evolu's codec records it.                                                                                                                                                                                                                                                                                                                                                                                               |
| [SqliteParameterCountError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteParameterCountError)                   | A run supplied a different number of parameters than the SQL has, or [SqliteDatabase.exec](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteDatabase#exec), which supplies none, met a statement with parameters.                                                                                                                                                                                                                                                                                                                                                 |
| [SqliteRandomSourceError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteRandomSourceError)                       | The random source failed while Evolu's codec encrypted a page, so the write failed with SQLITE_IOERR_WRITE. What the source threw went to the instance's `ReportDefect`.                                                                                                                                                                                                                                                                                                                                                                                              |
| [SqliteRunResult](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteRunResult)                                       | The result of [SqliteStatement.run](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteStatement#run).                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| [SqliteScratch](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteScratch)                                           | Reusable memory for output parameters and bind values, allocated once per database instead of once per call.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [SqliteShortWriteError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteShortWriteError)                           | A write that stored fewer or more bytes than requested.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [SqliteStatement](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteStatement)                                       | A prepared statement. Running or disposing it during its own run, as from a callback, throws.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| [SqliteVfsFailure](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteVfsFailure)                                     | A failure a pool's method recorded before returning an error code.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [SqliteVfsIoError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteVfsIoError)                                     | The storage of a pool failed outside SQLite, as when [SahPool.unlink](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool#unlink) deletes a file.                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [SqliteVfsPathError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteVfsPathError)                                 | Error returned when a string is not a valid [SqliteVfsPath](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/SqliteVfsPath).                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [SqliteWasm](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasm)                                                 | A loaded SQLite wasm instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| [SqliteWasmBuildMismatchError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasmBuildMismatchError)             | The binary's [sqliteWasmBuildHash](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api/variables/sqliteWasmBuildHash) differs, so it is not the build the generated code describes.                                                                                                                                                                                                                                                                                                                                                                                             |
| [SqliteWasmCompileError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasmCompileError)                         | The source could not be fetched, compiled or instantiated, its memory could not be allocated, its static constructors failed, or the module that installs the default VFS's methods could not be compiled.                                                                                                                                                                                                                                                                                                                                                            |
| [SqliteWasmDep](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasmDep)                                           | Dependency wrapper for [SqliteWasm](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasm).                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [SqliteWasmFunction](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasmFunction)                                 | A JavaScript function to install into the function table.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| [SqliteWasmFunctions](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasmFunctions)                               | Functions installed by [installWasmFunctions](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/installWasmFunctions).                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| [SqliteWasmInitializeError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasmInitializeError)                   | `sqlite3_initialize` failed, or allocating, finding or registering the default VFS did, for example when out of memory.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| [SqliteWasmUnknownImportError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteWasmUnknownImportError)             | The binary declares imports the loader does not implement.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [SubtleCryptoDep](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SubtleCryptoDep)                                       | WebCrypto, which derives legacy keys.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

## Type Aliases

| Type Alias                                                                                      | Description                                                                                                                                                                                                                                                                                                        |
| ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [CStringPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/CStringPtr)                       | A NUL-terminated UTF-8 string.                                                                                                                                                                                                                                                                                     |
| [NullPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/NullPtr)                             | The C NULL pointer.                                                                                                                                                                                                                                                                                                |
| [OpfsName](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/OpfsName)                           | The name of a file or directory in OPFS, a [valid file name](https://fs.spec.whatwg.org/#valid-file-name) of the File System Standard on every platform in one spelling: not empty, not `.` or `..`, without `/` or ``, which is a path separator on Windows, without NUL or a lone surrogate, and in Unicode NFC. |
| [SahPoolError](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SahPoolError)                   | Why [openSahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/openSahPool) failed.                                                                                                                                                                                                                               |
| [SqliteBackupPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteBackupPtr)             | An online backup from one connection's database to another's, `sqlite3_backup*`.                                                                                                                                                                                                                                   |
| [SqliteCodecError](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteCodecError)           | What Evolu's codec found wrong.                                                                                                                                                                                                                                                                                    |
| [SqliteContextPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteContextPtr)           | The context of an application-defined function call, `sqlite3_context*`.                                                                                                                                                                                                                                           |
| [SqliteDatabaseOptions](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteDatabaseOptions) | How to open a database.                                                                                                                                                                                                                                                                                            |
| [SqliteDbPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteDbPtr)                     | An open database connection, `sqlite3*`.                                                                                                                                                                                                                                                                           |
| [SqliteDestructor](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteDestructor)           | The destructor argument of `sqlite3_bind_text`, `sqlite3_bind_blob`, `sqlite3_result_text` and `sqlite3_result_blob`.                                                                                                                                                                                              |
| [SqliteExecError](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteExecError)             | Why [SqliteDatabase.exec](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteDatabase#exec) failed.                                                                                                                                                                                                              |
| [SqliteFailure](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteFailure)                 | A failure the pool or Evolu's codec recorded, which [SqliteError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteError) carries.                                                                                                                                                                             |
| [SqliteFilenamePtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteFilenamePtr)         | A database filename SQLite created, `sqlite3_filename`, as `xOpen` receives it.                                                                                                                                                                                                                                    |
| [SqliteFilePtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteFilePtr)                 | A file SQLite opened through a VFS, `sqlite3_file*`.                                                                                                                                                                                                                                                               |
| [SqliteFunctionPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteFunctionPtr)         | A C function pointer, which in wasm is an index into the function table, not a memory address.                                                                                                                                                                                                                     |
| [SqliteIndexInfoPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteIndexInfoPtr)       | The query planner's exchange with a virtual table's `xBestIndex`, `sqlite3_index_info*`.                                                                                                                                                                                                                           |
| [SqliteKeyDerivation](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteKeyDerivation)     | Which key opened an encrypted database: the raw key, or the key 2.2.4 derived from it because of a bug in SQLite3 Multiple Ciphers, which [deriveLegacySqliteKey](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/deriveLegacySqliteKey) describes.                                                                  |
| [SqliteOperation](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteOperation)             | The operation a [SqliteError](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteError) comes from.                                                                                                                                                                                                              |
| [SqliteOwnedCStringPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteOwnedCStringPtr) | A NUL-terminated UTF-8 string in memory allocated with `sqlite3_malloc`, which the holder frees with `sqlite3_free`.                                                                                                                                                                                               |
| [SqliteOwnedPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteOwnedPtr)               | Memory allocated with `sqlite3_malloc`.                                                                                                                                                                                                                                                                            |
| [SqliteOwnedValuePtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteOwnedValuePtr)     | A protected value copied with `sqlite3_value_dup`, which the holder frees with `sqlite3_value_free`.                                                                                                                                                                                                               |
| [SqlitePrepareError](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqlitePrepareError)       | Why [SqliteDatabase.prepare](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteDatabase#prepare) failed.                                                                                                                                                                                                        |
| [SqliteRunError](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteRunError)               | Why [SqliteStatement.run](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteStatement#run) failed.                                                                                                                                                                                                              |
| [SqliteStmtPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteStmtPtr)                 | A prepared statement, `sqlite3_stmt*`.                                                                                                                                                                                                                                                                             |
| [SqliteValuePtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteValuePtr)               | A dynamically typed SQL value, `sqlite3_value*`, such as a column value or an argument of an application-defined function.                                                                                                                                                                                         |
| [SqliteVfsMethod](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteVfsMethod)             | A VFS or I/O method that can record a [SqliteVfsFailure](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteVfsFailure).                                                                                                                                                                                         |
| [SqliteVfsPath](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteVfsPath)                 | The canonical path of a database file on a [SahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool), such as `/evolu1.db`, one spelling per file, as [SahPool.getPaths](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool#getpaths) lists it.                                                        |
| [SqliteVfsPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteVfsPtr)                   | A VFS struct, `sqlite3_vfs*`.                                                                                                                                                                                                                                                                                      |
| [SqliteWasmError](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteWasmError)             | Why [createSqliteWasm](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/createSqliteWasm) failed.                                                                                                                                                                                                                     |
| [SqliteWasmSource](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/SqliteWasmSource)           | The wasm binary, compiled or not.                                                                                                                                                                                                                                                                                  |
| [WasmPtr](https://evolu.dev/docs/api-reference/sqlite-wasm/type-aliases/WasmPtr)                             | An address in the wasm heap.                                                                                                                                                                                                                                                                                       |

## Variables

| Variable                                                                                               | Description                                                                                                                                                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [maxInt32](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/maxInt32)                                     | The largest C int.                                                                                                                                                                                                                                                                                                 |
| [maxSqliteInt64](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/maxSqliteInt64)                         | The largest SQLite INTEGER, 2^63 - 1.                                                                                                                                                                                                                                                                              |
| [minSqliteInt64](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/minSqliteInt64)                         | The smallest SQLite INTEGER, -2^63.                                                                                                                                                                                                                                                                                |
| [OpfsName](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/OpfsName)                                     | The name of a file or directory in OPFS, a [valid file name](https://fs.spec.whatwg.org/#valid-file-name) of the File System Standard on every platform in one spelling: not empty, not `.` or `..`, without `/` or ``, which is a path separator on Windows, without NUL or a lone surrogate, and in Unicode NFC. |
| [sahPoolDefaultCapacity](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolDefaultCapacity)         | The number of slots setup ensures: a database, its journal, and spares.                                                                                                                                                                                                                                            |
| [sahPoolDigestV2Flag](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolDigestV2Flag)               | The flag that marks a header digest as version 2.                                                                                                                                                                                                                                                                  |
| [sahPoolHeaderCorpusSize](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolHeaderCorpusSize)       | The size of the path and flags, which the digest covers.                                                                                                                                                                                                                                                           |
| [sahPoolHeaderDigestOffset](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolHeaderDigestOffset)   | Where the header's digest, two platform-endian u32 values, starts.                                                                                                                                                                                                                                                 |
| [sahPoolHeaderFlagsOffset](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolHeaderFlagsOffset)     | Where the header's big-endian u32 flags start, after the path.                                                                                                                                                                                                                                                     |
| [sahPoolHeaderPathSize](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolHeaderPathSize)           | The bytes reserved for the NUL-padded path at the start of the header.                                                                                                                                                                                                                                             |
| [sahPoolHeaderSize](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolHeaderSize)                   | The size of a slot's header, where the file's data starts.                                                                                                                                                                                                                                                         |
| [sahPoolMaxDatabasePathSize](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolMaxDatabasePathSize) | The longest path of a database a pool opens, in UTF-8 bytes, 498. SQLite names the other files of a database by appending a suffix to its path, at most the 12 bytes of a super-journal's `-mjXXXXXX9XX`, and each path must fit a slot's header with its NUL, as opfs-sahpool requires, which allows 510 bytes.   |
| [sahPoolOpaqueDirectoryName](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolOpaqueDirectoryName) | The pool subdirectory that holds the slots. Renaming it orphans them.                                                                                                                                                                                                                                              |
| [sahPoolPersistentFileTypes](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolPersistentFileTypes) | The file types that persist across sessions: SQLITE_OPEN_MAIN_DB, SQLITE_OPEN_MAIN_JOURNAL, SQLITE_OPEN_SUPER_JOURNAL and SQLITE_OPEN_WAL, combined. A slot with another type is freed at setup.                                                                                                                   |
| [SqliteVfsPath](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/SqliteVfsPath)                           | The canonical path of a database file on a [SahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool), such as `/evolu1.db`, one spelling per file, as [SahPool.getPaths](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SahPool#getpaths) lists it.                                                        |
| [sqliteWasmUrl](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sqliteWasmUrl)                           | The URL of the wasm binary the package ships, to load with [createSqliteWasm](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/createSqliteWasm).                                                                                                                                                                     |

## Functions

| Function                                                                                                     | Description                                                                                                                                                                                                                        |
| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [allocCString](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/allocCString)                                   | Copies a string into new memory as a NUL-terminated UTF-8 C string, which the caller frees with `sqlite3_free`.                                                                                                                    |
| [allocWasm](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/allocWasm)                                         | Allocates at least one byte with `sqlite3_malloc`, so a zero-length value keeps a non-NULL address.                                                                                                                                |
| [computeSahPoolDigest](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/computeSahPoolDigest)                   | Computes the digest of a header's first [sahPoolHeaderCorpusSize](https://evolu.dev/docs/api-reference/sqlite-wasm/variables/sahPoolHeaderCorpusSize) bytes, as opfs-sahpool does.                                                              |
| [copyWasmBytes](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/copyWasmBytes)                                 | Copies bytes out of wasm memory into a new `ArrayBuffer`, so the result can be transferred to another worker.                                                                                                                      |
| [createEncryptedSqliteDatabase](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/createEncryptedSqliteDatabase) | Opens an EncryptedFile database on a pool, falling back to the key `@evolu/sqlite-wasm` 2.2.4 derived.                                                                                                                             |
| [createSqliteDatabase](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/createSqliteDatabase)                   | Opens a database.                                                                                                                                                                                                                  |
| [createSqliteScratch](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/createSqliteScratch)                     | Creates a [SqliteScratch](https://evolu.dev/docs/api-reference/sqlite-wasm/interfaces/SqliteScratch).                                                                                                                                           |
| [createSqliteWasm](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/createSqliteWasm)                           | Loads the wasm, following the steps in the module documentation.                                                                                                                                                                   |
| [deriveLegacySqliteKey](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/deriveLegacySqliteKey)                 | Derives the key `@evolu/sqlite-wasm` 2.2.4 used: PBKDF2-HMAC-SHA512 with 256000 iterations and a 32-byte output, over the UTF-8 text `x'` followed by the key in lowercase hex and `'`, salted with the database's first 16 bytes. |
| [initializeSqliteWasm](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/initializeSqliteWasm)                   | Initializes the library as loading steps 6 and 7 do, for use after `sqlite3_shutdown` and `sqlite3_config`.                                                                                                                        |
| [installWasmFunctions](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/installWasmFunctions)                   | Installs functions into the function table.                                                                                                                                                                                        |
| [isInt32](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/isInt32)                                             | Whether a number is a 32-bit integer, which binds with `sqlite3_bind_int` without a BigInt.                                                                                                                                        |
| [isSqliteInt64](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/isSqliteInt64)                                 | Whether a bigint fits a SQLite INTEGER.                                                                                                                                                                                            |
| [openSahPool](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/openSahPool)                                     | Opens the pool in a directory, registering its VFS on first use.                                                                                                                                                                   |
| [readCString](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/readCString)                                     | Decodes a NUL-terminated C string, such as an error message or a column name.                                                                                                                                                      |
| [readUtf8](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/readUtf8)                                           | Decodes UTF-8 of a known byte length, such as a text column, keeping a leading byte order mark and embedded NUL characters.                                                                                                        |
| [sqliteResultCodeToPrimary](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/sqliteResultCodeToPrimary)         | Returns the primary result code of a result code, its low 8 bits, such as SQLITE_CONSTRAINT for SQLITE_CONSTRAINT_NOTNULL. A primary result code returns itself.                                                                   |
| [writeUtf8](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/writeUtf8)                                         | Encodes a string as UTF-8 into existing memory and returns the byte length, without a NUL terminator.                                                                                                                              |
| [writeWasmBytes](https://evolu.dev/docs/api-reference/sqlite-wasm/functions/writeWasmBytes)                               | Copies bytes into wasm memory.                                                                                                                                                                                                     |

## References

<a id="sqliteprimaryresultcode"></a>

### SqlitePrimaryResultCode

Re-exports [SqlitePrimaryResultCode](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api/type-aliases/SqlitePrimaryResultCode)

---

<a id="sqliteresultcode"></a>

### SqliteResultCode

Re-exports [SqliteResultCode](https://evolu.dev/docs/api-reference/sqlite-wasm/c-api/type-aliases/SqliteResultCode)