On this page
This page contains information to quickly get Realm Database integrated into your app. Before you begin, ensure you have:
Check Out the Tutorial
This page contains only the essential information that you need to set up an Atlas App Services backend. If you prefer to follow a guided tutorial that shows you step-by-step how to set up a working app, check out the React Native Tutorial where you'll build a mobile app that connects to the Task Tracker backend.
At the top of your source files where you want to use Realm, add the following line to import the SDK.
To use App Services features such as authentication and sync, you must access your App using your App ID. You can find your App ID in the App Services UI.
Get Schema from UI if Development Mode Disabled
If you have enabled Sync but turned off Development Mode, you can copy and paste the object model definitions that App Services generated for you from the SDKs tab in the App Services UI. You must re-enable Development Mode if you want to make changes to the object model definition from client side code.
When you have enabled anonymous authentication in the App Services UI, users can immediately log into your app without providing any identifying information:
Realm provides many additional ways to authenticate, register, and link users.
To create a new Task run the method "realm.create()" inside the "realm.write()" callback. Pass the string "Task" as the first parameter to "realm.create()". Pass a task object as the second parameter.
You can retrieve a live collection of all tasks in the realm:
You can also filter that collection using a filter:
To modify a task, update its properties in a write transaction block:
Finally, you can delete a task:
You cannot watch for changes if the data source is an Atlas serverless instance. MongoDB serverless currently does not support change streams, which are used on watched collections to listen for changes.
To stop watching for changes, run the "realm.removeAllListeners()" method. Alternatively, to remove a specific listener, call "removeListener()" on the object that is being watched and pass in the listener function:
Once logged in, you can log out: