{"id":26272996,"url":"https://github.com/theorib/op-sqlite-turso-expo-react-native","last_synced_at":"2025-10-12T12:46:17.361Z","repository":{"id":248399351,"uuid":"828579174","full_name":"theorib/op-sqlite-turso-expo-react-native","owner":"theorib","description":"This projects is a test ground for connecting a Turso database to an Expo/React Native project using op-sqlite with libsql leveraging Turso's embedded replicas.","archived":false,"fork":false,"pushed_at":"2024-07-25T16:00:33.000Z","size":639,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-13T01:45:22.725Z","etag":null,"topics":["expo","libsql","op-sqlite","react","react-native","sqlite","turso","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theorib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-07-14T15:15:22.000Z","updated_at":"2025-03-29T16:06:28.000Z","dependencies_parsed_at":"2025-06-13T01:38:12.957Z","dependency_job_id":"bd607c3f-274c-4f28-9c1a-ac69fba843af","html_url":"https://github.com/theorib/op-sqlite-turso-expo-react-native","commit_stats":null,"previous_names":["theorib/op-sqlite-expo-turso-test","theorib/op-sqlite-turso-expo-react-native"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theorib/op-sqlite-turso-expo-react-native","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorib%2Fop-sqlite-turso-expo-react-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorib%2Fop-sqlite-turso-expo-react-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorib%2Fop-sqlite-turso-expo-react-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorib%2Fop-sqlite-turso-expo-react-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theorib","download_url":"https://codeload.github.com/theorib/op-sqlite-turso-expo-react-native/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theorib%2Fop-sqlite-turso-expo-react-native/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260868909,"owners_count":23074961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expo","libsql","op-sqlite","react","react-native","sqlite","turso","typescript"],"created_at":"2025-03-14T08:14:08.089Z","updated_at":"2025-10-12T12:46:17.352Z","avatar_url":"https://github.com/theorib.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testing op-sqlite with Turso on an Expo/React Native project\n\n## Table of Contents\n\n1. [Description](#description)\n2. [Supported Platforms](#supported-platforms)\n3. [Prerequisites](#prerequisites)\n4. [Steps to make this project work](#steps-to-make-this-project-work)\n   - [Clone, download or fork the project](#1-clone-download-or-fork-the-project)\n   - [Install dependencies](#2-install-dependencies)\n   - [Create a new turso database and populate it](#3-create-a-new-turso-database-and-populate-it)\n   - [Create a project build and run it](#4-create-a-project-build-and-run-it-in-your-ios-or-android-simulators)\n   - [Start the project](#5-start-the-project-at-any-time)\n5. [Troubleshooting](#troubleshooting)\n6. [Extra info](#extra-info)\n\n## Description\n\nThis projects is a test ground for connecting a [Turso](https://turso.tech) database to an [Expo/React Native](https://docs.expo.dev) project using [op-sqlite](https://github.com/OP-Engineering/op-sqlite) (set up to use [libsql](https://ospfranco.notion.site/Libsql-Support-c56ac2afb939460182ee7bd910b08fbf) as the database source) leveraging Turso's [embedded replicas](https://docs.turso.tech/features/embedded-replicas/introduction).\n\nTurso's embedded replicas allow database reads and/or writes to always happen from a local SQLite database first, providing very fast reads and/or writes which are then synced to a remote database.\n\nThe project is currently set up to leverage Turso's main features of interest such as:\n\n- Embedded replicas\n- [Offline writes](https://turso.tech/blog/turso-offline-sync-public-beta) with sync\n- Local database [encryption at rest](https://docs.turso.tech/features/embedded-replicas/introduction#encryption-at-rest)\n- [Periodic sync](https://docs.turso.tech/features/embedded-replicas/introduction#periodic-sync)\n- [Read your writes](https://docs.turso.tech/features/embedded-replicas/introduction#read-your-writes)\n\n## Project Structure\n\nThe main `src/app/index.tsx` file allows for displaying, adding, deleting and refreshing a list of items from the database. New items are automatically generated for demonstration purposes.\n\nThe `src/db` folder is where most of the op-sqlite code is located.\n\n- The `src/db/index.ts` creates and exports the database client as well as a sync function.\n- The `src/db/schema.ts` file currenly mainly contains TypeScript types\n- The `src/db/queries.ts` file contains query functions to retrieve data from the database\n- The `src/db/mutations.ts` file contains insert and delete functions\n- The `src/db/seedData.ts` file mainly contains a function to create data on the fly using faker.js\n\n## Suported Platforms\n\nThis project was created on a Mac with an M1 chip running MacOS Sequoia 15.5.\n\n- For Android builds it should work on most computers that have the correct development environment set up.\n- For iOS builds you will likelly need a work on MacOS computer.\n\n## Prerequisites\n\nThis project assumes you have an Expo/React Native development environment already. If you don't, you can follow the relevant steps below:\n\n- Install [Node.js](https://nodejs.org/en/) LTS version\n- Install [Expo command line tools](https://docs.expo.dev/more/expo-cli/)\n- For Android builds follow [this guide](https://docs.expo.dev/get-started/set-up-your-environment/?platform=android\u0026device=simulated\u0026mode=development-build\u0026buildEnv=local) to install and configure OpenJDK, Android Studio, and an Android Emulator\n- For iOS buids (Mac users only), follow [this guide](https://docs.expo.dev/get-started/set-up-your-environment/?platform=ios\u0026device=simulated\u0026mode=development-build\u0026buildEnv=local) to install and configure Xcode, an iOS simulator and [watchman](https://facebook.github.io/watchman/docs/install#macos)\n  - You will likely need [Homebrew](https://brew.sh) to manage packages in your Mac.\n\n## Steps to make this project work:\n\nYou can use your favorite package manager. I'm using [pnpm](https://pnpm.io) in this example. But you can replace any `pnpm` in the scripts section of the project's `package.json` to calls for `npm` or `yarn`. If you do, also make sure to replace any `pnpm dlx` with `npx` (if using `npm`) or `yarn dlx` (if using `yarn`).\n\n### 1. Clone, download or fork this repository\n\n```bash\ngit clone https://github.com/theorib/op-sqlite-turso-expo-react-native.git\n```\n\n### 2. install dependencies\n\n```bash\npnpm install\n```\n\n### 3. Create a new turso database and populate it:\n\n1. If you don't have it already, begin by installing the Turso CLI:\n\n```bash\nbrew install tursodatabase/tap/turso\n```\n\n2. Authenticate or create a new account with Turso\n\n```bash\nturso auth signup\n```\n\n3. Create a new database (replace db-name with the name you want to give to your database)\n\n```bash\nturso db create db-name\n```\n\n4. Seed the database with the included sql dump file\n\n```bash\nturso db shell db-name \u003c dbDump/dump.sql\n```\n\n5. Get your new database URL\n\n```bash\nturso db show db-name\n```\n\n6. Get an authentication token for the database\n\n```bash\nturso db tokens create db-name\n```\n\n7. Rename the `.env.sample` file in the root of this project folder to `.env` and replace the value of the environment variables with the URL and authentication token you got from the previous two steps\n\n### 4. Create a project build and run it in your iOS or Android simulators\n\n```bash\npnpm ios\npnpm android\n```\n\n### 5. Start the project at any time\n\n```bash\npnpm start\n```\n\n## Troubleshooting\n\nIf you are running into problems with your iOS build try running a pod install first with\n\n```bash\npnpm pod\n```\n\n## Extra info\n\nThis projects uses a nearly \"vanilla\" installation of Expo with very few changes. Most notably:\n\n- [TanStack Query](https://tanstack.com/query/latest) to make data fetching and syncing with Turso more straightforward while handling pending and loading states properly\n- [op-sqlite](https://github.com/OP-Engineering/op-sqlite) is installed as a dependency since this is what we are testing\n- [faker-js](https://fakerjs.dev/) is installed to provide mock data\n- [expo-dev-client](https://docs.expo.dev/versions/latest/sdk/dev-client/) to allow for Expo custom builds (necessary when using op-sqlite)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheorib%2Fop-sqlite-turso-expo-react-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheorib%2Fop-sqlite-turso-expo-react-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheorib%2Fop-sqlite-turso-expo-react-native/lists"}