Realm Database

React Native 7 min min read Updated: Aug 03, 2026 Advanced
Realm Database
Advanced Topic 5 of 15

Realm Database

Realm is a fast, object-oriented mobile database designed specifically for mobile applications, offering an alternative to SQLite with a simpler, object-based API.

Installing Realm

bash npm install realm @realm/react

Defining a Schema

javascript class Task extends Realm.Object {} Task.schema = { name: 'Task', properties: { _id: 'int', title: 'string', isComplete: { type: 'bool', default: false }, }, primaryKey: '_id', };

Setting Up the Realm Provider

javascript import { RealmProvider } from '@realm/react'; function App() { return ( ); }

Writing Data

javascript realm.write(() => { realm.create('Task', { _id: 1, title: 'Learn Realm' }); });

Querying Data

javascript import { useQuery } from '@realm/react'; function TaskList() { const tasks = useQuery(Task); return {item.title}} />; }

Live Updating Queries

Realm queries automatically update the UI whenever underlying data changes, without requiring manual refetching, thanks to its live object system.

Realm vs SQLite

Realm offers a more intuitive, object-oriented API and automatic reactivity compared to SQLite’s traditional SQL-based approach, though SQLite remains valuable for teams already familiar with SQL syntax.

Conclusion

Realm provides a modern, reactive database solution for React Native applications requiring robust local data storage with an intuitive, object-oriented API and automatic UI updates.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators