[!NOTE]
Realm is now Atlas Device SDK - Learn More
The Realm Database
Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript & TypeScript implementation of Realm. Currently, we support React Native (JSC & Hermes on iOS & Android), Node.js and Electron (on Windows, MacOS and Linux).
What are the Atlas Device SDKs?
The Atlas Device SDKs are a collection of language and platform specific SDKs, each with a suite of app development tools optimized for data access and persistence on mobile and edge devices. Use the SDKs to build data-driven mobile, edge, web, desktop, and IoT apps.
It might help to think of the Realm database as the persistance layer of the Atlas Device SDKs.
Features
Mobile-first: Realm is the first database built from the ground up to run directly inside phones, tablets and wearables.
Simple: Data is directly exposed as objects and queryable by code, removing the need for ORM's riddled with performance & maintenance issues.
Modern: The database supports relationships, generics, and vectorization.
Fast: It is faster than even raw SQLite on common operations, while maintaining an extremely rich feature set.
The Atlas Device SDK for React Native provides persistence of objects and advanced queries for persisted objects. You can have easier integration with React Native by using @realm/react.
Template apps
We have TypeScript templates to help you get started using Realm. Follow the links to your desired template and follow the instructions there to get up and running fast.
Need help with your code?: Look for previous questions on the #realm tag — or ask a new question. You can also check out our Community Forum where general questions about how to do something can be discussed.
Have a bug to report?Open an issue. If possible, include the version of Realm, a full log, the Realm file, and a project that shows the issue.
Have a feature request?Open an issue. Tell us what the feature should do, and why you want the feature.
Realm is not compatible with the legacy Chrome Debugger. The following debugging methods are supported:
Hermes Debugger is the recommended way for debugging modern React Native apps.
Safari also has a similar feature set, but requires some setup and only supports debugging in iOS.
NOTE: For the above methods, it is not necessary to enable Debug with Chrome in the Debug Menu.
Building the SDK
For instructions on building the SDK from the source, see the building.md file.
Troubleshooting missing binary
It's possible after installing and running Realm that one encounters the error Could not find the Realm binary. Here are are some tips to help with this.
Compatibility
Consult our COMPATIBILITY.md to ensure you are running compatible version of realm with the supported versions of node, react-native or expo.
React Native
iOS
Typically this error occurs when the pod dependencies haven't been updating. Try running the following command
npx pod-install
If that still doesn't help it's possible there are some caching errors with your build or your pod dependencies. The following commands can be used to safely clear these caches:
Afterwards, reinstall pods and try again. If this still doesn't work, ensure that node_modules/realm/react-native/ios/realm-js-ios.xcframework exists and contains a binary for your architecture. If this is missing, try reinstalling the `realm`` npm package.
Android
This can occur when installing realm and not performing a clean build. The following commands can be used to clear your cache:
cd android
./gradlew clean
Afterwards, try and rebuild for Android. If you are still encountering problems, ensure that node_moduels/realm/react-native/android/src/main/jniLibs contains a realm binary for your architecture. If this is missing, try reinstalling the realm npm package.
Expo
If you are using Expo, a common pitfall is not installing the expo-dev-client and using the Development Client specific scripts to build and run your React Native project in Expo. The Development Client allows you to create a local version of Expo Go which includes 3rd party libraries such as Realm. If you would like to use realm in an Expo project, the following steps can help.
install the expo-dev-client:
npm install expo-dev-client
build the dev client for iOS
npx expo run:ios
build the dev client for Android
npx expo run:android
start the bundler without building
npx expo start --dev-client
Node/Electron
When running npm install realm the realm binaries for the detected architecture are downloaded into node_modules/realm/prebuilds. If this directory is missing or empty, ensure that there weren't any network issues reported on installation.
Analytics
Asynchronously submits install information to Realm.
Why are we doing this? In short, because it helps us build a better product
for you. None of the data personally identifies you, your employer or your
app, but it will help us understand what language you use, what Node.js
versions you target, etc. Having this info will help prioritizing our time,
adding new features and deprecating old features. Collecting an anonymized
application path & anonymized machine identifier is the only way for us to
count actual usage of the other metrics accurately. If we don’t have a way to
deduplicate the info reported, it will be useless, as a single developer
npm install-ing the same app 10 times would report 10 times more than another
developer that only installs once, making the data all but useless.
No one likes sharing data unless it’s necessary, we get it, and we’ve
debated adding this for a long long time. If you truly, absolutely
feel compelled to not send this data back to Realm, then you can set an env
variable named REALM_DISABLE_ANALYTICS.
Currently the following information is reported:
What version of Realm is being installed.
The OS platform and version which is being used.
If a JavaScript framework (currently React Native and Electron) is used and its version.
Which JavaScript engine is being used.
Node.js version number.
TypeScript version if used.
An anonymous machine identifier and hashed application name to aggregate the other information on.
Moreover, we unconditionally write various constants to a file which we might use at runtime.
[!NOTE]
This version bumps the Realm file format to version 24. It is not possible to downgrade to earlier versions. Older files will automatically be upgraded to the new file format. Files created by Realm JavaScript prior to v6.0.0, might not be upgradeable. Only Realm Studio 15.0.0 or later will be able to open the new file format.
[!NOTE]
This version communicates with Atlas Device Services through a different URL (https://services.cloud.mongodb.com). While we consider this an internal detail of the SDK, you might need to update rules in firewalls or other configuration that you've used to limit connections made by your app.
Storage of Decimal128 properties has been optimized so that the individual values will take up 0 bits (if all nulls), 32 bits, 64 bits or 128 bits depending on what is needed. ([realm/realm-core#6111]https://github.com/realm/realm-core/pull/6111))
Querying a specific entry in a collection (in particular 'first and 'last') is supported. (realm/realm-core#4269)
You can set the threshold levels for trace output on individual categories. (realm/realm-core#7004)
Improved performance of RQL queries on a non-linked string property using >, >=, <, <= operators and fixed behavior that a null string should be evaluated as less than everything, previously nulls were not matched. (realm/realm-core#3939)
Added support for using aggregate operations on Mixed properties in queries. (realm/realm-core#7398)
Improved file compaction performance on platforms with page sizes greater than 4k (for example arm64 Apple platforms) for files less than 256 pages in size. (realm/realm-core#7492)
Added the ability to set the log level for one or more categories via Realm.setLogLevel. (#6560)
Added detection and better instructions when imported from the Expo Go app. (#6523)
Fixed
Aligned Dictionaries to Lists and Sets when they get cleared. (#6205, since v10.3.0-rc.1)
Fixed equality queries on a Mixed property with an index possibly returning the wrong result if values of different types happened to have the same StringIndex hash. (realm/realm-core#6407, since v10.5.0-beta.1)
@count/@size is now supported for Mixed properties. (realm/realm-core#7280, since v10.0.0)
Fixed queries like indexed_property == NONE {x} which mistakenly matched on only x instead of not x. This only applies when an indexed property with equality (==, or IN) matches with NONE on a list of one item. If the constant list contained more than one value then it was working correctly. (realm/realm-java#7862, since v10.20.0)
Uploading the changesets recovered during an automatic client reset recovery may lead to Bad server version errors and a new client reset. (realm/realm-core#7279, since v12.5.0)
Fixed crash in full text index using prefix search with no matches (realm/realm-core#7309, since v12.2.0)
Fixed a race condition when backing up Realm files before a client reset which could have lead to overwriting an existing file. (realm/realm-core#7341)
Fixed a bug when removing items from a list that could result in invalidated links becoming visible which could cause crashes or exceptions when accessing those list items later on. This affects synced Realms where another client had previously removed a list with over 1000 items in it, and then further local removals from the same list caused the list to have fewer than 1000 items. (#7414, since v10.0.0)
Fixed opening a Realm with cached user while offline results in fatal error and session does not retry connection. (#6554 and #6558, since v12.6.0)
Fixed sorting order of strings to use standard unicode codepoint order instead of grouping similar English letters together. A noticeable change will be from "aAbBzZ" to "ABZabz". (realm/realm-core#2573)
data and string are now strongly typed for comparisons and queries. This change is especially relevant when querying for a string constant on a Mixed property, as now only strings will be returned. If searching for data is desired, then that type must be specified by the constant. In RQL the new way to specify a binary constant is to use mixed = bin('xyz') or mixed = binary('xyz'). (realm/realm-core#6407)
Fixed diverging history due to a bug in the replication code when setting default null values (embedded objects included). (realm/realm-core#7536)
Null pointer exception may be triggered when logging out and async commits callbacks not executed. (realm/realm-core#7434, since v12.6.0)
Fixed a bug which caused crashes when reloading React Native apps. (#6579, since v12.0.0)
Compatibility
React Native >= v0.71.4
Realm Studio v15.0.0.
File format: generates Realms with format v24 (reads and upgrades file format v10 or later).
Internal
The base URL used to communicate with the Atlas App Services was changed from "https://realm.mongodb.com" to "https://services.cloud.mongodb.com". (realm/realm-core#7534).
Realm by MongoDB is an offline-first mobile database: an alternative to SQLite and key-value stores
The npm package realm receives a total of 28,930 weekly downloads. As such, realm popularity was classified as popular.
We found that realm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 5 open source maintainers collaborating on the project.
Package last updated on 17 Apr 2024
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."