npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-native-crosssqlite

v0.1.1

Published

Cross Platform SQLite for React Native

Readme

react-native-crosssqlite

🗄️ Cross-Platform SQLite for React Native - A high-performance SQLite Turbo Module that works seamlessly across iOS, Android, and Windows platforms.

✨ Features

  • 🚀 High Performance: Built as a React Native Turbo Module with C++ core
  • 🌍 Cross-Platform: Supports iOS, Android, and Windows
  • 📱 Native SQLite: Uses native SQLite3 library on each platform
  • 🔄 WAL Mode: Optimized with Write-Ahead Logging for better performance
  • 📊 JSON Results: SELECT queries return results in JSON format
  • 🛡️ Type Safe: Full TypeScript support with proper type definitions

📦 Installation

npm install react-native-crosssqlite

Platform Setup

iOS

No additional setup required. The module will be automatically linked.

Android

No additional setup required. The module will be automatically linked.

Windows

  1. Install React Native Windows CLI:
    npm install -g @react-native-windows/cli
  2. Initialize Windows support in your project:
    npx @react-native-windows/cli@latest init --overwrite

🚀 Usage

Basic Example

import * as SQLite from 'react-native-crosssqlite';

// Open a database
const result = SQLite.open('/path/to/database.db');
if (result === 0) {
  console.log('Database opened successfully');
}

// Create a table
SQLite.exec(`
  CREATE TABLE IF NOT EXISTS users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    email TEXT UNIQUE
  );
`);

// Insert data
SQLite.exec(`
  INSERT INTO users (name, email)
  VALUES ('John Doe', '[email protected]');
`);

// Query data
const users = SQLite.select('SELECT * FROM users;');
console.log('Users:', JSON.parse(users));

// Check journal mode (should be 'wal')
const journalMode = SQLite.getJournalMode();
console.log('Journal mode:', journalMode);

// Close database
SQLite.close();

Platform-Specific Database Paths

import { Platform } from 'react-native';
import RNFS from '@dr.pogodin/react-native-fs';

const getDatabasePath = (): string => {
  if (Platform.OS === 'ios') {
    return `${RNFS.DocumentDirectoryPath}/myapp.db`;
  } else if (Platform.OS === 'android') {
    return `${RNFS.ExternalDirectoryPath}/myapp.db`;
  } else if (Platform.OS === 'windows') {
    return 'myapp.db'; // Relative to app directory
  }
  return 'myapp.db';
};

SQLite.open(getDatabasePath());

📚 API Reference

open(path: string): number

Opens a SQLite database at the specified path.

  • Returns: 0 on success, error code on failure
  • Note: Automatically enables WAL mode for better performance

exec(sql: string): number

Executes a SQL statement (INSERT, UPDATE, DELETE, CREATE, etc.).

  • Returns: 0 on success, error code on failure

select(sql: string): string

Executes a SELECT query and returns results as JSON.

  • Returns: JSON string array of result rows

close(): void

Closes the currently open database.

getJournalMode(): string

Returns the current journal mode of the database.

  • Returns: Journal mode string (typically "wal")

multiply(a: number, b: number): number

Utility function for testing the module.

  • Returns: Product of two numbers

🏗️ Architecture

This module uses a shared C++ core with platform-specific bindings:

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   iOS (Obj-C)   │    │ Android (JNI)   │    │ Windows (WinRT) │
└─────────┬───────┘    └─────────┬───────┘    └─────────┬───────┘
          │                      │                      │
          └──────────────────────┼──────────────────────┘
                                 │
                    ┌─────────────▼─────────────┐
                    │     C++ SQLite Bridge     │
                    │   (sqlite_bridge.cpp)     │
                    └─────────────┬─────────────┘
                                  │
                    ┌─────────────▼─────────────┐
                    │      SQLite3 Library      │
                    │      (sqlite3.c)          │
                    └───────────────────────────┘

🧪 Example App

Check out the example app in the example/ directory to see the module in action:

cd example
npm install

# For iOS
npx react-native run-ios

# For Android
npx react-native run-android

# For Windows (after setup)
npx react-native run-windows

🚀 Releases

This package uses automated releases through GitHub Actions. See RELEASE.md for details on how to create releases and publish to npm.

npm version GitHub release

🤝 Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

📄 License

MIT


Made with create-react-native-library