To use this app you must have a SelfDB instance running locally or remotely.
Don’t have SelfDB yet? Grab a your self-hostable copy https://selfdb.io and follow the installation guide on our website.
This Expo React Native application demonstrates how to use SelfDB as the backend while following mobile best-practices. It ships with:
- 🔐 Authentication (context provider, login / register screens, persistent session)
- 🗄️ Database CRUD (topics & comments with file upload)
- 📡 Real-time ready subscriptions
- 🏗️ Modular project structure (components, contexts, types, services)
- Node.js ≥ 18
- Expo CLI (
npm i -g expo-cli) - A running SelfDB instance (local or remote)
-
Clone the repo
git clone https://github.com/Selfdb-io/selfdb-expo-app cd selfdb-expo-app -
Configure the environment
cp .env.example .env # then open `.env` and set:EXPO_PUBLIC_SELFDB_URL=http://localhost:8000 EXPO_PUBLIC_SELFDB_STORAGE_URL=http://localhost:8001 EXPO_PUBLIC_SELFDB_ANON_KEY=your_key_here
-
Install dependencies
npm install
-
Install additional tools (if needed)
# Install Watchman (improves file watching performance) brew update && brew install watchman # Install Expo Dev Client for better debugging npx expo install expo-dev-client
-
Start the development server
npx expo start # general development npx expo run:ios # iOS simulator/device
- Create the required tables in SelfDB Dashboard:
-- Create topics table
CREATE TABLE IF NOT EXISTS topics (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
title VARCHAR(255) NOT NULL,
content TEXT NOT NULL,
author_name VARCHAR(100) NOT NULL,
user_id UUID,
file_id UUID,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create comments table
CREATE TABLE IF NOT EXISTS comments (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
topic_id UUID NOT NULL REFERENCES topics(id),
content TEXT NOT NULL,
author_name VARCHAR(100) NOT NULL,
user_id UUID,
file_id UUID,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create indexes for better performance
CREATE INDEX IF NOT EXISTS idx_comments_topic_id ON comments(topic_id);
CREATE INDEX IF NOT EXISTS idx_topics_user_id ON topics(user_id);
CREATE INDEX IF NOT EXISTS idx_comments_user_id ON comments(user_id);
CREATE INDEX IF NOT EXISTS idx_topics_created_at ON topics(created_at);
CREATE INDEX IF NOT EXISTS idx_comments_created_at ON comments(created_at);- Create a public storage bucket named
discussion.
- Update
.envwith your production SelfDB credentials. - Test the authentication flow and data operations.
- Extend the UI or schemas as needed—the foundation is already wired up for you.