Docs Menu

Docs HomeRealm

Work with Realm Files - React Native SDK

On this page

  • Realm Files
  • In-Memory Realms
  • Find a Realm File Path

Realms are the core data structure used to organize data in Realm Database. At its core, a realm is a collection of the objects that you use in your application, called Realm objects, as well as additional metadata that describe the objects.

Realm Database stores a binary encoded version of every object and type in a realm in a single .realm file. The file is located at a specific path that you define when you open the realm.

Tip

Implement Compacting in Your Production Application

Every production application should implement a shouldCompactOnLaunch callback to periodically reduce the realm file size.

Note

Auxiliary Realm Files

Realm Database creates additional files for each realm.

Warning

Use Caution When Deleting Realm Files

In some circumstances, such as a client reset scenario, you might need to delete a realm file and its auxiliary files.

If you delete a realm file or any of its auxiliary files while one or more instances of the realm are open, you might corrupt the realm or disrupt sync.

You may safely delete these files when all instances of a realm are closed. Before you delete a realm file, make sure that you back up any important objects as you will lose all unsynced data in the realm.

You can also open a realm entirely in memory, which will not create a .realm file or its associated auxiliary files. Instead the SDK stores objects in memory while the realm is open and discards them immediately when all instances are closed.

The realm file is located at a specific path that you can optionally define when you open the realm.

// Open a realm.
const realm = await Realm.open({
schema: [Car],
});
// Get on-disk location of the Realm
const realmFileLocation = realm.path;
console.log(`Realm file is located at: ${realm.path}`);
←  Bootstrap with Expo - React Native SDKConfigure a Realm - React Native SDK →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.