Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6d2c70a
fix: preserve Unicode SQLite paths on Windows
chrispader Nov 30, 2026
20c67ec
fix: cover Windows database paths and bind attachment aliases
chrispader Dec 1, 2026
40ab873
ci: install Nitro headers for standalone C++ test changes
chrispader Dec 1, 2026
de8b665
fix: preserve quoted attachment aliases and native CI coverage
chrispader Dec 1, 2026
9f4a187
fix: retain whitespace around legacy quoted aliases
chrispader Dec 1, 2026
e1451e2
fix: preserve SQLite alias whitespace and route host dependencies
chrispader Dec 1, 2026
c982f99
fix: preserve directory permissions and bare aliases
chrispader Dec 1, 2026
f72f67c
fix: preserve cached SQL keys during index removal
chrispader Dec 1, 2026
8e8eda8
feat: add React Native Windows support for Nitro SQLite
chrispader Nov 30, 2026
e7ca42e
test: validate named and raw Windows BLOB results
chrispader Nov 30, 2026
6992c1d
fix: avoid the WinNT DELETE macro in SQLite registration
chrispader Nov 30, 2026
523ff11
ci: use the installed Windows SDK for the smoke app
chrispader Nov 30, 2026
8323e0e
fix(windows): validate the destination for SQLite BLOB results
chrispader Nov 30, 2026
a2fa9d5
fix: align Windows SQLite defaults and expose runtime diagnostics
chrispader Dec 1, 2026
63ef5de
fix: keep Windows diagnostics safe on allocation failures
chrispader Dec 1, 2026
f6e525a
test: expose Windows smoke progress and preserve rollback errors
chrispader Dec 1, 2026
a0a21a8
fix: scope Windows smoke accessibility queries to app windows
chrispader Dec 1, 2026
bd072b5
ci: capture Windows smoke startup failures and crash dumps
chrispader Dec 1, 2026
d5e16f4
docs: clarify Windows diagnostic metadata
chrispader Dec 1, 2026
eb0ec23
chore: merge main into fix/windows-sqlite-paths
chrispader Dec 1, 2026
477e733
chore: merge fix/windows-sqlite-paths into feat/windows-support
chrispader Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/ci-paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"packages/react-native-nitro-sqlite/tests/cpp/**"
],
"cpp_tests": [
"package.json",
"bun.lock",
"bunfig.toml",
"example/package.json",
"packages/react-native-nitro-sqlite/package.json",
".github/workflows/**",
".github/actions/**",
".github/ci-paths.json",
Expand All @@ -64,15 +69,25 @@
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteDatabaseConnections.*",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteExecuteBatch.*",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteOperations.*",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteImportSqlFile.*",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteLogs.hpp",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteTypes.hpp",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteQueryResults.hpp",
"packages/react-native-nitro-sqlite/nitrogen/generated/shared/**",
"patches/react-native-nitro-modules*",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteUtils.hpp",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteStatementGroup.hpp",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteStatementCache.hpp",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteException.hpp",
"packages/react-native-nitro-sqlite/cpp/NitroSQLiteStatementTail.hpp",
"packages/react-native-nitro-sqlite/cpp/sqlite/sqlite3.*",
"packages/react-native-nitro-sqlite/cpp/sqlite/sqlite3-symbol-prefix.h",
"packages/react-native-nitro-sqlite-vec/cpp/**",
"packages/react-native-nitro-sqlite/tests/cpp/**",
"scripts/generate-sqlite-symbol-prefix.py",
"scripts/test-private-sqlite-symbols.sh",
"scripts/test-cpp.sh"
"scripts/test-cpp.sh",
"scripts/prepare-cpp-test-headers.cjs"
],
"docs": [
".github/workflows/**",
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/test-windows-native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Test Windows SQLite files

on:
push:
branches: [main]
pull_request:
paths:
- '.github/workflows/test-windows-native.yml'
- 'packages/react-native-nitro-sqlite/cpp/**'
- 'packages/react-native-nitro-sqlite/tests/cpp/**'
- 'packages/react-native-nitro-sqlite/nitrogen/generated/shared/**'
- 'scripts/prepare-cpp-test-headers.cjs'
- 'patches/react-native-nitro-modules*'
- 'package.json'
- 'bun.lock'
workflow_dispatch:

permissions:
contents: read

jobs:
sqlite-files:
runs-on: windows-2025
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.1
- run: bun install --frozen-lockfile --ignore-scripts
- name: Build and run path, connection and migration tests with MSVC
shell: pwsh
run: |
$PSNativeCommandUseErrorActionPreference = $true
$visualStudio = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
Import-Module "$visualStudio\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath $visualStudio -SkipAutomaticLocation -DevCmdArguments '-arch=x64'
$package = Resolve-Path packages/react-native-nitro-sqlite
Set-Location $env:RUNNER_TEMP
cl /nologo /c /TC /DSQLITE_THREADSAFE=2 "$package\cpp\sqlite\sqlite3.c" /Fosqlite3.obj
cl /nologo /std:c++20 /EHsc /utf-8 "/I$package\cpp" `
"$package\cpp\NitroSQLiteDatabaseConnections.cpp" "$package\cpp\NitroSQLiteDatabaseMigration.cpp" `
"$package\tests\cpp\databaseConnections.test.cpp" sqlite3.obj /FedatabaseConnectionsTests.exe
.\databaseConnectionsTests.exe
cl /nologo /std:c++20 /EHsc /utf-8 "/I$package\cpp" "/I$package\cpp\sqlite" `
"$package\cpp\NitroSQLiteDatabaseMigration.cpp" "$package\tests\cpp\databaseMigration.test.cpp" `
sqlite3.obj /FedatabaseMigrationTests.exe
.\databaseMigrationTests.exe
cl /nologo /std:c++20 /EHsc /O2 /DNDEBUG /utf-8 "/I$package\cpp" `
"$package\tests\cpp\statementCache.test.cpp" sqlite3.obj /FestatementCacheTests.exe
.\statementCacheTests.exe
Set-Location $env:GITHUB_WORKSPACE
node scripts/prepare-cpp-test-headers.cjs "$env:RUNNER_TEMP/headers"
$includes = @("/I$env:RUNNER_TEMP\headers", "/I$env:RUNNER_TEMP\headers\NitroModules", "/I$env:GITHUB_WORKSPACE\node_modules\react-native\ReactCommon\jsi", "/I$package\cpp", "/I$package\cpp\sqlite", "/I$package\cpp\hybridObjects", "/I$package\nitrogen\generated\shared\c++")
$standardHeaders = "/FI$package\tests\cpp\NitroTestStandardHeaders.hpp"
$nitro = "$env:GITHUB_WORKSPACE\node_modules\react-native-nitro-modules\cpp\core"
$jsi = "$env:GITHUB_WORKSPACE\node_modules\react-native\ReactCommon\jsi\jsi\jsi.cpp"
Set-Location $env:RUNNER_TEMP
cl /nologo /std:c++20 /EHsc /utf-8 @includes $standardHeaders `
"$package\cpp\NitroSQLiteDatabaseConnections.cpp" "$package\cpp\NitroSQLiteDatabaseMigration.cpp" `
"$package\cpp\NitroSQLiteOperations.cpp" "$package\cpp\NitroSQLiteImportSqlFile.cpp" `
"$nitro\core\ArrayBuffer.cpp" $jsi "$package\tests\cpp\databasePaths.test.cpp" `
sqlite3.obj /FedatabasePathsTests.exe
.\databasePathsTests.exe
cl /nologo /c /std:c++20 /EHsc /utf-8 @includes $standardHeaders "$package\cpp\hybridObjects\HybridNitroSQLite.cpp"
79 changes: 79 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build and test React Native Windows

on:
pull_request:
paths:
- '.github/workflows/test-windows.yml'
- 'example/windows/**'
- 'packages/react-native-nitro-sqlite/**'
workflow_dispatch:

permissions:
contents: read

jobs:
windows:
name: React Native Windows x64 smoke test
runs-on: windows-2025
timeout-minutes: 45
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.1
- name: Verify Release debugger logging
run: |
$PSNativeCommandUseErrorActionPreference = $true
$visualStudio = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
Import-Module "$visualStudio\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath $visualStudio -SkipAutomaticLocation -DevCmdArguments '-arch=x64'
$package = Resolve-Path packages/react-native-nitro-sqlite
Set-Location $env:RUNNER_TEMP
cl /nologo /std:c++20 /EHsc /utf-8 /DNDEBUG "/I$package\cpp" "$package\tests\cpp\windowsLogs.test.cpp" /FewindowsLogsTests.exe
.\windowsLogsTests.exe
- name: Pack Nitro SQLite
working-directory: packages/react-native-nitro-sqlite
run: |
$app = Join-Path $env:RUNNER_TEMP 'nitro-sqlite-windows'
Copy-Item -Recurse ../../example/windows $app
bun pm pack --ignore-scripts --filename "$app/nitro-sqlite.tgz"
"SMOKE_APP=$app" >> $env:GITHUB_ENV
- name: Install dependencies and generate the Windows app
run: |
Set-Location $env:SMOKE_APP
bun install --frozen-lockfile --ignore-scripts
bun run windows:init
bun add ./nitro-sqlite.tgz --ignore-scripts
- name: Build and open the x64 Release app
run: |
"SMOKE_STARTED_AT=$([DateTimeOffset]::UtcNow.ToString('o'))" >> $env:GITHUB_ENV
$dumps = Join-Path $env:RUNNER_TEMP 'nitro-sqlite-dumps'
New-Item -ItemType Directory -Force $dumps | Out-Null
$key = 'HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\NitroSQLiteWindowsSmoke.exe'
New-Item -Force $key | Out-Null
New-ItemProperty -Force $key -Name DumpFolder -PropertyType ExpandString -Value $dumps | Out-Null
New-ItemProperty -Force $key -Name DumpType -PropertyType DWord -Value 2 | Out-Null
New-ItemProperty -Force $key -Name DumpCount -PropertyType DWord -Value 2 | Out-Null
Set-Location $env:SMOKE_APP
bun run windows:build --logging --msbuildprops "WindowsTargetPlatformVersion=10.0.26100.0,TargetPlatformVersion=10.0.26100.0"
- name: Check native SQLite results in the app
shell: powershell
run: |
Set-Location $env:SMOKE_APP
./assert-smoke.ps1
- name: Save native startup diagnostics
if: failure()
uses: actions/upload-artifact@v7
with:
name: windows-smoke-startup
retention-days: 7
if-no-files-found: warn
path: |
${{ runner.temp }}/nitro-sqlite-dumps/**
${{ env.SMOKE_APP }}/windows/x64/Release/**/*.pdb
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<br />

Nitro SQLite is a SQLite library for React Native on iOS, macOS, visionOS, and Android, built with [Nitro Modules](https://nitro.margelo.com/). It provides synchronous and asynchronous queries, transactions, and batch operations.
Nitro SQLite is a SQLite library for React Native on iOS, macOS, visionOS, Android, and Windows, built with [Nitro Modules](https://nitro.margelo.com/). It provides synchronous and asynchronous queries, transactions, and batch operations.

The bundled SQLite build enables [R\*Tree indexes](https://sqlite.margelo.com/docs/concepts/queries-and-indexes#query-spatial-ranges) by default on Apple platforms and Android. Set `nitroSQLite.enableRTree` to `false` in your app's `package.json` to omit it from the native build.

Expand All @@ -18,7 +18,7 @@ If you use a coding agent, give it the [NitroSQLite skill](https://github.com/ma

## Installation

Requires React Native 0.75 or newer and `react-native-nitro-modules` 0.37.1 or newer.
Requires React Native 0.75 or newer and `react-native-nitro-modules` 0.37.1 or newer. [Windows](https://sqlite.margelo.com/docs/configuration/windows) requires a packaged x64 React Native Windows 0.85 app and exactly Nitro Modules 0.37.2.

```sh
npm install react-native-nitro-sqlite react-native-nitro-modules
Expand Down
4 changes: 3 additions & 1 deletion docs/content/docs/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Add the options you want to change to your app's `package.json`. These are the d
}
```

Windows uses these defaults but does not read this configuration block. See the [Windows build limits](/docs/configuration/windows) before changing settings for a Windows app.

All values are booleans. Rebuild your app after changes; on Apple platforms, install Pods again first.

## Thread safety
Expand All @@ -33,4 +35,4 @@ WAL databases default to `synchronous = NORMAL`, which can lose recent commits a

When supplying custom flags, omit `SQLITE_ENABLE_RTREE` to disable it. Defining it as `0` still enables the module.

For platform settings and alternative build flags, see [iOS](/docs/configuration/ios), [Android](/docs/configuration/android), or [macOS](/docs/configuration/macos).
For platform settings and alternative build flags, see [iOS](/docs/configuration/ios), [Android](/docs/configuration/android), [macOS](/docs/configuration/macos), or [Windows](/docs/configuration/windows).
2 changes: 1 addition & 1 deletion docs/content/docs/configuration/meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"title": "Configuration",
"pages": ["expo", "ios", "android", "macos"]
"pages": ["expo", "ios", "android", "macos", "windows"]
}
42 changes: 42 additions & 0 deletions docs/content/docs/configuration/windows.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Windows
description: Install Nitro SQLite in a packaged React Native Windows app.
---

SQLite stores a database in a local file and can create journal files beside it. On Windows, Nitro SQLite uses the packaged app's per-user LocalState directory by default. Pass an app-controlled database name and relative `location` when selecting a subdirectory. The [database path rules](/docs/guides/database-lifecycle) allow path components such as `..`, so a supplied path can resolve outside LocalState.

Use a packaged WinAppSDK x64 app with the React Native Windows 0.85 C++ template and its matching React Native version. Follow the [React Native Windows setup guide](https://microsoft.github.io/react-native-windows/docs/getting-started) for Visual Studio and Windows SDK requirements.

Install Nitro SQLite and pin Nitro Modules to exactly **0.37.2**. The Windows build rejects every other Nitro Modules version, including newer versions. The broader peer dependency range applies to the other platforms:

```sh
npm install --save-exact react-native-nitro-sqlite react-native-nitro-modules@0.37.2
```

Add this dependency override to your app's `react-native.config.js`. Nitro SQLite's Windows project builds the Nitro runtime and registers the `NitroModules` provider.

```js
module.exports = {
dependencies: {
'react-native-nitro-modules': { platforms: { windows: null } },
},
}
```

Rebuild the app to autolink Nitro SQLite:

```sh
npx react-native run-windows --arch x64
```

Use the same [database lifecycle API](/docs/guides/database-lifecycle) as on the other native platforms. Reading a BLOB on Windows copies its bytes into a JavaScript `ArrayBuffer`.

The Windows DLL builds its own Nitro core and registers the app's single `NitroModules` provider. A second library that bundles another Nitro core, or a future Windows implementation of `react-native-nitro-modules`, conflicts with that provider and its separate HybridObject registry. Objects registered by one library can then be unavailable to the other. Do not autolink two providers. If another library needs its own Windows Nitro runtime, use separate app configurations until both libraries support a shared runtime. Disabling a provider alone does not join their registries.

Windows uses bundled SQLite with thread safety, RTree, and the same default [performance-mode flags](/docs/configuration#performance-mode) as the other platforms. Use single quotes for SQL strings. WAL databases default to `synchronous = NORMAL`; set `PRAGMA synchronous = FULL` per connection if you need that durability.

The Windows project does not read the `nitroSQLite` block in your app's `package.json`. `threadSafe`, `performanceMode`, and `enableRTree` are fixed on. `enableBatchAtomicWrite`, Android's `nitroSqliteFlags`, and the Apple environment and Pod settings do not configure Windows. Custom SQLite flags, system SQLite, SQLite SEE, and sqlite-vec are unsupported.

Use a packaged x64 app. Unpackaged apps return an initialization error that explains the packaged-app requirement. ARM64 and Nitro V1 are unsupported.

SQLite warnings and errors appear in Visual Studio's Debug Output through `OutputDebugStringW`, including in Release builds. Attach a debugger to the app process to read them. Messages can include database and table names and exception text without redaction. Avoid sensitive data in those identifiers, and review captured diagnostics before sharing them.
12 changes: 11 additions & 1 deletion docs/content/docs/guides/attach-databases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ db.close()

The example assumes the tables and files already exist. SQLite can create the attached file when it is missing, so verify the intended path when opening prepopulated data. `attach()` and `detach()` are synchronous connection operations; they fail while the connection queue is busy. A failed attach or detach throws `NitroSQLiteError` through the connection wrapper.

Only pass database names, locations, and aliases you control. The library does not bind these as parameters. Query values still belong in `?` parameters. See [database lifecycle](/docs/guides/database-lifecycle) for the location convention and the generated [`NitroSQLiteConnection` reference](/api/react-native-nitro-sqlite/interfaces/NitroSQLiteConnection) for signatures.
NitroSQLite binds the filename and schema alias as parameters, including Unicode characters and apostrophes. Aliases can contain spaces or quotes. Quote a schema name as an SQL identifier when using it in a query. Query values still belong in `?` parameters.

Pass literal filenames. If older code doubled apostrophes to work around SQL interpolation, remove that escaping: `café's.sqlite` names a different file from `café''s.sqlite`.

For compatibility, a complete alias enclosed in double quotes, single quotes, backticks, or square brackets is interpreted as the existing quoted name. For example, `db.attach('archive.sqlite', '"sales archive"')` and `db.attach('archive.sqlite', 'sales archive')` both attach the schema `sales archive`. Either form works with `detach()` too. Doubled quote characters inside a quoted name are decoded. Square brackets have no escape syntax.

A full pair of quotes is ambiguous with a literal name that includes those quote characters. Legacy quoting takes precedence. To name a schema `"archive"` including its quote characters, pass the SQL-quoted alias `'"""archive"""'` to both `attach()` and `detach()`. Other raw aliases are preserved, including incomplete quoting. Aliases are never executed as SQL.

Surrounding SQL whitespace is ignored for a single bare identifier too: `' archive '` resolves to `archive`. To retain that whitespace as part of the name, use the quoted alias `'" archive "'`. Names with internal spaces remain literal raw names.

Only pass database names and locations you control. Path segments such as `..` are not validated. See [database lifecycle](/docs/guides/database-lifecycle) for the location convention and the generated [`NitroSQLiteConnection` reference](/api/react-native-nitro-sqlite/interfaces/NitroSQLiteConnection) for signatures.
2 changes: 2 additions & 0 deletions docs/content/docs/guides/database-lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const db = open({ name: 'catalog.sqlite', location: 'databases' })

Only pass database names and locations you control. The library does not validate path segments such as `..`.

SQLite treats an attached database name as a filename and its alias as a schema name. `attach()` preserves Unicode characters and apostrophes in filenames, including on Windows. Aliases can contain spaces and quotes. Complete SQL-quoted aliases retain their legacy meaning; see [attachment alias compatibility](/docs/guides/attach-databases#file-paths-and-aliases). Use a quoted SQL identifier when querying such an alias, and pass the same alias form to `detach()`.

To open a prepopulated database, copy the SQLite file into the intended app directory before calling `open()`. Use the same `name` and `location` when you open it. A missing file creates a new, empty database, so verify the copy if your schema must already exist. See [file lifetimes](/docs/concepts/databases-and-connections#file-lifetimes) for WAL companion files.

The platform pages describe the database roots and storage settings for [iOS](/docs/configuration/ios#database-location), [Android](/docs/configuration/android#database-location), and [macOS](/docs/configuration/macos). The generated [`NitroSQLiteConnection` reference](/api/react-native-nitro-sqlite/interfaces/NitroSQLiteConnection) lists the lifecycle methods.
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: Getting Started
description: Install Nitro SQLite, rebuild your React Native app, and run your first query.
---

Nitro SQLite gives React Native apps a local SQLite database on iOS, macOS, visionOS, and Android. Start by installing its native package and Nitro Modules, then open a database with `open()`.
Nitro SQLite gives React Native apps a local SQLite database on iOS, macOS, visionOS, and Android. Windows apps can use the [Windows setup guide](/docs/configuration/windows). Start by installing the native package and Nitro Modules, then open a database with `open()`.

## 1. Install the packages

Nitro SQLite requires React Native 0.75 or newer, React 17 or newer, and `react-native-nitro-modules` 0.37.1 or newer.
Nitro SQLite requires React Native 0.75 or newer, React 17 or newer, and `react-native-nitro-modules` 0.37.1 or newer. Windows requires exactly Nitro Modules 0.37.2 and a packaged x64 React Native Windows 0.85 app.

```sh
npm install react-native-nitro-sqlite react-native-nitro-modules
Expand Down
Loading
Loading