Why Use Realm Swift?

check

Fast and lightweight

Fast and lightweight Realm’s lazy loading and zero-copy architecture means the UI loads in microseconds, so you can build data rich apps without creating lag or draining device resources.
check

Simple to start and scale

Easily integrate Realm into your XCode project with SPM, or your favorite package manager, and start creating classes. No ORM or DAO required. Realm’s integration with SwiftUI automatically updates your views so you don’t have to.
check

Built-in mobile to cloud sync

Real-time mobile to cloud data sync makes it easy to build interactive features that keep data up-to-date across multiple devices, users, and the backend.

What does storing and querying data in Realm look like?

Work with intuitive APIs

Idiomatic APIs and powerful queries help you get to market faster with less code.
// Define your models like regular Swift classes
class Dog: Object {
    @Persisted var name: String
    @Persisted var age: Int
}
class Person: Object {
    @Persisted(primaryKey: true) var _id: String
    @Persisted var name: String
    @Persisted var age: Int
    // Create relationships by pointing an Object field to another Class
    @Persisted var dogs: List<Dog>;
}
// Use them like regular Swift objects
let dog = Dog()
dog.name = "Rex"
dog.age = 1
print("name of dog: (dog.name)")

// Get the default Realm
let realm = try! Realm()
// Persist your data easily with a write transaction 
try! realm.write {
    realm.add(dog)

Build reactive apps with live objects

Realm’s live objects mean data updated anywhere is automatically updated everywhere.
// Open the default realm.
let realm = try! Realm()
var token: NotificationToken?

let dog = Dog()
dog.name = "Max"

// Create a dog in the realm.
try! realm.write {
    realm.add(dog)
}

//  Set up the listener & observe object notifications.
token = dog.observe { change in
    switch change {
    case .change(let properties):
        for property in properties {
            print("Property '(property.name)' changed to '(property.newValue!)'");
        }
    case .error(let error):
        print("An error occurred: (error)")
    case .deleted:
        print("The object was deleted.")
    }
}

// Update the dog's name to see the effect.
try! realm.write {
    dog.name = "Wolfie"
}

Enjoy direct integration with SwiftUI

Realm’s integration with SwiftUI automatically updates your views for you.
struct ContactsView: View {
    @ObservedResults(Person.self) var persons
    
    var body: some View {
        List {
            ForEach(persons) { person in
                TextField(“name”, person.bind(.name))(
            }
            .onDelete(perform: $persons.remove)
        }.navigationBarItems(trailing:
            Button("Add") {
                $persons.append(Person())
            }
        )
    }
}

Apps built with Realm Swift

Many applications use Realm Swift – from chart-topping apps in the App Store to the world’s smallest cloud-hosted, SwiftUI chat app. Learn how Realm helps teams build better apps, faster.
"Realm makes the data persistence layer so easy on iOS. We have a big advantage in terms of developer speed and general feature development."
- Senior iOS Developer, Atlassian
Atlassian
Imgur
NurseGrid
LucidChart

Featured resources

Realm Quick Start

The fastest way to get started with the Realm local database. It includes copyable code examples and all the essential information you need.

Complete Realm Tutorial

Learn how to create an iOS task tracker app that allows users to manage a personal list of tasks using Realm. Then, enhance your app to include real-time, mobile to cloud sync functionality.

Deploy Realm in minutes

Deploy an iOS, Android, or cross-platform “To Do” app with real-time sync in minutes.