Docs Menu
Docs Home
/ /
Atlas Device SDKs

Upgrade from Stitch to Realm - Node.js SDK

On this page

  • Overview
  • New Features
  • Changes

If you have an existing app built with the Stitch SDK, you should migrate your app to use the new Realm SDK. While much of the application logic and flow of information hasn't changed, there are a few changes to how it connects to the realm backend.

Note

This page presents how to migrate from the MongoDB Stitch Server SDK to the Realm JS SDK, to build Node.js Applications.

If you are looking to build web apps, consider our Upgrade from Stitch to Realm Web page. If you are looking to develop React Native apps, consider our Upgrade from Stitch to Realm for React Native page.

  • The Realm Node SDK now includes Realm Database, which includes local object storage and the ability to synchronize document changes across devices over the internet.

What's Changed?
Solution
The backend app connections previously accessed via StitchAppClient are now available through Realm.App. Use the Realm.App class to access authentication functionality such as logging in and getting the current user.
Migrate all occurrences of StitchAppClient to Realm.App.
StitchUser was previously the interface to access application users, but now it is Realm.User.
Migrate all occurrences of StitchUser to Realm.User.
Rewrite all authentication logic to use the new login API.
The API to log users out has changed from stitchAppClient.auth.logout() to Realm.User.logOut().
Rewrite the application logic to log out using the Realm.User object's logOut() method.
The Stitch SDK required developers to import authentication credentials from the "mongodb-stitch-server-sdk". The Realm SDK has a class, Realm.Credentials, that creates credentials for each authentication provider.
Replace imports of authentication credentials with method calls for each respective authentication provider through the Realm.Credentials class.
Instead of calling Atlas Functions using the app client directly via the Stitch SDK method stitchAppClient.callFunction(),call Realm server functions using the callFunction() method of a logged-in Realm.User.
Call Atlas Functions using Realm.User.callFunction() instead of an app client.
The interface to the MongoDB Data Access API, containing objects like MongoDatabase, and MongoCollection, has changed. Through Stitch, passing the RemoteMongoClient.Factory and the string "mongodb-atlas" to StitchAppClient.getServiceClient() would create a remote Mongodb client. The Realm JS SDK creates a remote MongoDB client through the Realm.User.mongoClient method on the user object.
Replace all mongoClient instantiations with Realm.User.mongoClient.
The Realm SDKs do not provide an interface for calling Services (like the Twilio and AWS services).
Convert references to Third Party Services (AWS or Twilio) in your Stitch Application to Realm functions in your Realm application using the corresponding npm packages. For more information, see Add External Dependencies.
 →