Introduction to Realm Database
On this page
This introduction explains the Realm product for mobile application developers. After reading, you should understand:
- What Realm is and what problems it solves.
- How Atlas App Services interacts with Realm Database.
- The benefits of Realm compared to traditional mobile development stacks.
What Problem Does Realm Solve?
Mobile developers face a number of unique challenges. You must:
- Handle the unpredictable environment of mobile apps. Connections can be lost, devices can shut down at any time, and clients often update long after release.
- Maintain common data schemas and APIs between mobile clients, backend APIs, and databases.
- Stay aware of security vulnerabilities across all components in an ecosystem.
- Consistently serialize objects between networks, database storage, and application memory.
- Program in the languages and frameworks for one or more mobile operating systems.
All of these challenges present different obstacles. You can solve each in isolation with a wide variety of libraries and frameworks. Deciding the right solution for each problem with the right tradeoffs is a challenge mobile developers know all too well.
The combination of multiple environments creates even more challenges. For instance, you can use a Java library on your Android client to serialize objects, but that library likely wouldn't work on iOS. And this doesn't even take into account consistency across backend services.
Realm Database
Many of these challenges arise due to particularities of the mobile environment. These challenges include network reliability, local storage, and keeping UIs reactive. Realm Database solves many common mobile programming headaches:
- Local storage: Realm Database runs right on client devices. Access objects using the native query language for each platform. Storing, accessing, and updating your data is simple and lightweight.
- Network reliability: Realm Database is offline-first. You always read from and write to the local database, not over the network. When Atlas Device Sync is enabled, Realm Database synchronizes data with Atlas App Services over the network in a background thread. The sync protocol resolves conflicts consistently on each client and in the linked MongoDB Atlas cluster.
- Reactive UI: Live objects always reflect the latest data stored in Realm Database. You can subscribe to changes, letting you keep your UI consistently up to date.
The Realm SDK lets you connect to local realms for Android, iOS, Node.js, React Native, and UWP development.
MongoDB Atlas
Client applications generate a lot of data. Whether it's uploaded reviews and ratings, posts and comments on a blog, or inventory in a kitchen, you need to store that data somewhere. MongoDB Atlas provides cloud-hosted managed instances of MongoDB that are always available.
Atlas supports aggregations and other complex workloads with the full capabilities of MongoDB. You can connect to your Atlas instance in your backend services using MongoDB drivers for a wide range of languages. Or connect your Atlas instance to MongoDB Charts to visualize your data in real time. Storing your data in Atlas makes it easy to share data across users and platforms.
Atlas App Services
Atlas App Services provides services to fulfill several common application backend requirements:
- Realm Users and Authentication provide built-in user management. Integrate with third-party authentication providers, like Facebook, Google, and Apple.
- Realm Functions provide server-side logic for your App. You can call App Services Functions from the Realm SDK in your client application.
- Realm Triggers automatically execute a function at a scheduled time or when an event occurs, such as a change to a database or a call to a HTTP endpoint.
- Realm Rules let you control who accesses what data.
- Realm Values and Realm Secrets enable you to define global variables and private credentials once and use them across your entire App.
- The GraphQL API lets you access data stored in a linked MongoDB cluster using any standard GraphQL client.
Get Started with Realm
Check out our Task Tracker tutorial for any of these platforms:
Or start by experimenting with a working Sync-enabled client application with a template app.
You can also refer to the documentation for each client SDK:
- Java SDK for Kotlin and Java
- Swift SDK for Swift and Objective-C
- .NET SDK for C# / Xamarin
- React Native SDK for TypeScript and JavaScript
- Flutter SDK (Preview) for Flutter
Summary
- Realm Database is an offline-first mobile object database in which you can directly access and store live objects without an ORM.
Live Objects and Atlas Device Sync offer significant benefits over traditional mobile development stacks:
- Live Objects always reflect the latest state of data in the database, making it easier to keep your UI in sync with changes to your data.
- Atlas Device Sync synchronizes data between client-side realms and the server-side MongoDB Atlas cluster linked to your App.
- Realm Database synchronizes data in a background thread, abstracting away network usage so you don't have to worry about latency or dropped connections.
- Realm is a serverless application platform that takes care of the details of deployment and scaling for you.
- You can customize your App with functions and triggers, custom permissions via rules, and authentication.