Sync is hard, let us do it for you

Couchbase Mobile is developer-friendly and can run and sync data anywhere – in the cloud, at the edge, and directly on mobile and IoT devices. Build data-driven apps that always work, with or without internet.

Deliver apps that are fast, reliable, secure and consistent even without internet:

Speed

Guaranteed low latency and lightning-fast data access regardless of internet speed and bandwidth, essential for real-time, mission-critical applications.

Reliability

Uninterrupted access to data regardless of internet connectivity to provide reliable user experiences and 100% business uptime.

Security

Secures data in motion and at rest with encryption and fine-grained access control, ensures compliance with data privacy regulations.

Developer-friendly

Development is fast and easy with full SQL support, simple-to-use APIs for database operations, and comprehensive platform and language support.

Build better apps with a mobile database platform

Accelerated development

  • Native support for iOS, Android, and Windows platforms
  • .NET and Java support for desktop and web server apps
  • C-API for developing on nearly any embedded platform in any language
  • Full SQL support – reuse queries across platforms
  • Schema-less JSON format simplifies app upgrades without requiring tedious data migration

What does developing with Couchbase Mobile look like?

  // Create or open a database
let database: Database
do {
   database = try Database(name: "mydb")
} catch {
   fatalError("Error opening database")
}
// Create a new document (i.e. a record) in the database.
let mutableDoc = MutableDocument()
   .setFloat(2.0, forKey: "version")
   .setString("SDK", forKey: "type")
// Save it to the database.
do {
   try database.saveDocument(mutableDoc)
} catch {
   fatalError("Error saving document")
}
// Update a document.
if let mutableDoc = database.document(withID: mutableDoc.id)?.toMutable() {
   mutableDoc.setString("Swift", forKey: "language")
   do {
       try database.saveDocument(mutableDoc)
       let document = database.document(withID: mutableDoc.id)!
       // Log the document ID (generated by the database)
       // and properties
       print("Updated document id \(document.id), adding language \(document.string(forKey: "language")!)")
   } catch {
       fatalError("Error updating document")
   }
}
// Create a query to fetch documents of type SDK.
let query = QueryBuilder
   .select(SelectResult.all())
   .from(DataSource.database(database))
  .where(Expression.property("type").equalTo(Expression.string("SDK")))
// Run the query.
do {
   let result = try query.execute()
   print("Number of rows :: \(result.allResults().count)")
} catch {
   fatalError("Error running the query")
}
// Create replicators to push and pull changes to and from the cloud.
let targetEndpoint = URLEndpoint(url: URL(string: "ws://localhost:4984/getting-started-db")!)
var replConfig = ReplicatorConfiguration(database: database, target: targetEndpoint)
replConfig.replicatorType = .pushAndPull
 
// Add authentication.
replConfig.authenticator = BasicAuthenticator(username: "john", password: "pass")
 
// Create replicator (make sure to add an instance or static variable named replicator)
let replicator = Replicator(config: replConfig)
// Optionally,Listen to replicator change events.
replicator.addChangeListener { (change) in
if let error = change.status.error as NSError? {
       print("Error code :: \(error.code)")
     }
}
// Start replication.
replicator.start()
  // Create or open database
var database = new Database("mydb");
 
// Create a new document (i.e. a record) in the database
string id = null;
using (var mutableDoc = new MutableDocument())
{
   mutableDoc.SetFloat("version", 2.0f)
       .SetString("type", "SDK");
 
   // Save it to the database
   database.Save(mutableDoc);
   id = mutableDoc.Id;
}
 
// Update a document
using (var doc = database.GetDocument(id))
using (var mutableDoc = doc.ToMutable())
{
   mutableDoc.SetString("language", "C#");
   database.Save(mutableDoc);
 
   using (var docAgain = database.GetDocument(id))
   {
       Console.WriteLine($"Document ID :: {docAgain.Id}");
       Console.WriteLine($"Learning {docAgain.GetString("language")}");
   }
}
 
// Create a query to fetch documents of type SDK
// i.e. SELECT * FROM database WHERE type = "SDK"
using (var query = QueryBuilder.Select(SelectResult.All())
   .From(DataSource.Database(database))
   .Where(Expression.Property("type").EqualTo(Expression.String("SDK"))))
{
   // Run the query
   var result = query.Execute();
   Console.WriteLine($"Number of rows :: {result.AllResults().Count}");
}
 
// Create replicator to push and pull changes to and from the cloud
var targetEndpoint = new URLEndpoint(new Uri("ws://localhost:4984/getting-started-db"));
var replConfig = new ReplicatorConfiguration(database, targetEndpoint);
 
// Add authentication
replConfig.Authenticator = new BasicAuthenticator("john", "pass");
 
// Optionally, Create replicator (make sure to add an instance or static variable
// named _Replicator)
var _Replicator = new Replicator(replConfig);
_Replicator.AddChangeListener((sender, args) =>
{
   if (args.Status.Error != null)
   {
       Console.WriteLine($"Error :: {args.Status.Error}");
   }
});
 
// Start replicator
_Replicator.Start();
// Create or open a database
val cfg = DatabaseConfigurationFactory.create()
val database = Database(  "mydb", cfg)
​// Create a new document (i.e. a record) in the database.
var mutableDoc = MutableDocument().setFloat("version", 2.0f).setString("type", "SDK")
// Save it to the database.
database.save(mutableDoc)
​// Retrieve and update a document.
mutableDoc = database.getDocument(mutableDoc.id)!!.toMutable().setString("language", "Java")
database.save(mutableDoc)
// Retrieve immutable document and log the document ID generated by the database and some document properties
val document = database.getDocument(mutableDoc.id)!!
Log.i(TAG, "Document ID :: ${document.id}")
Log.i(TAG, "Learning ${document.getString("language")}")
​// Create a query to fetch documents of type SDK.
val rs = QueryBuilder.select(SelectResult.all())
  .from(DataSource.database(database))
  .where(Expression.property("type").equalTo(Expression.string("SDK")))
  .execute()
Log.i(TAG, "Number of rows :: ${rs.allResults().size}")
​
// Create a replicator to push and pull changes to and from the cloud.
val replicator = Replicator(
  ReplicatorConfigurationFactory.create(
      database = database,
      target = URLEndpoint(URI("ws://localhost:4984/getting-started-db")),
      type = ReplicatorType.PUSH_AND_PULL,
      authenticator = BasicAuthenticator("sync-gateway", "password".toCharArray())
  )
)
​// Optional, Listen to replicator change events.
replicator.addChangeListener { change ->
  val err = change.status.error
  if (err != null) {
      Log.i(TAG, "Error code ::  ${err.code}")
  }
}
​// Start replication.
replicator.start()
  // Open or create the database
CBLError err;
CBLDatabase* database = CBLDatabase_Open(FLSTR("mydb"), NULL, &err);
if(!database) {
   // Error handling.  For brevity, this is truncated in the rest of the snippet
   fprintf(stderr, "Error opening database (%d / %d)\n", err.domain, err.code);
   FLSliceResult msg = CBLError_Message(&err);
   fprintf(stderr, "%.*s\n", (int)msg.size, (const char *)msg.buf);
   FLSliceResult_Release(msg);
   return;
}
 
// Create a new document (i.e. a record) in the database
CBLDocument* mutableDoc = CBLDocument_Create();
FLMutableDict properties = CBLDocument_MutableProperties(mutableDoc);
FLMutableDict_SetFloat(properties, FLSTR("version"), 3.0f);
 
// Save it to the database
if(!CBLDatabase_SaveDocument(database, mutableDoc, &err)) {
   // Failed to save, do error handling as above
   return;
}
 
FLStringResult id = FLSlice_Copy(CBLDocument_ID(mutableDoc));
CBLDocument_Release(mutableDoc);
 
// Update a document
mutableDoc = CBLDatabase_GetMutableDocument(database, FLSliceResult_AsSlice(id), &err);
if(!mutableDoc) {
   return;
}
 
properties = CBLDocument_MutableProperties(mutableDoc);
FLMutableDict_SetString(properties, FLSTR("language"), FLSTR("C"));
if(!CBLDatabase_SaveDocument(database, mutableDoc, &err)) {
   return;
}
 
// Note const here, means readonly
const CBLDocument* docAgain = CBLDatabase_GetDocument(database, FLSliceResult_AsSlice(id), &err);
if(!docAgain) {
     return;
}
 
// No copy this time, so no release later (notice it is not FLStringResult this time)
FLString retrievedID = CBLDocument_ID(docAgain);
FLDict retrievedProperties = CBLDocument_Properties(docAgain);
FLString retrievedLanguage = FLValue_AsString(FLDict_Get(retrievedProperties, FLSTR("language")));
printf("Document ID :: %.*s\n", (int)retrievedID.size, (const char *)retrievedID.buf);
 
CBLDocument_Release(mutableDoc);
CBLDocument_Release(docAgain);
FLSliceResult_Release(id);
 
// Create a query to fetch documents of type SDK
int errorPos;
CBLQuery* query = CBLDatabase_CreateQuery(database, kCBLN1QLLanguage, FLSTR("SELECT * FROM _ WHERE type = \"SDK\""), &errorPos, &err);
if(!query) {
   // Failed to create query, do error handling as above
   // Note that errorPos will contain the position in the N1QL string
   // that the parse failed, if applicable
   return;
}
 
CBLResultSet* result = CBLQuery_Execute(query, &err);
if(!result) {
   // Failed to run query, do error handling as above
   return;
}
 
CBLResultSet_Release(result);
CBLQuery_Release(query);
 
// Create replicator to push and pull changes to and from the cloud
CBLEndpoint* targetEndpoint = CBLEndpoint_CreateWithURL(FLSTR("ws://localhost:4984/getting-started-db"), &err);
if(!targetEndpoint) {
   // Failed to create endpoint, do error handling as above
   return;
}
 
CBLReplicatorConfiguration replConfig;
CBLAuthenticator* basicAuth = CBLAuth_CreatePassword(FLSTR("john"), FLSTR("pass"));
memset(&replConfig, 0, sizeof(replConfig));
replConfig.database = database;
replConfig.endpoint = targetEndpoint;
replConfig.authenticator = basicAuth;
 
CBLReplicator* replicator = CBLReplicator_Create(&replConfig, &err);
CBLAuth_Free(basicAuth);
CBLEndpoint_Free(targetEndpoint);
if(!replicator) {
   // Failed to create replicator, do error handling as above
   return;
}
 
// Optionally, add replication listener
CBLListenerToken* token = CBLReplicator_AddChangeListener(replicator, getting_started_change_listener, NULL);
 
// Start the replicator
CBLReplicator_Start(replicator, false);

Related features and capabilities

Couchbase Lite: Embedded database

Couchbase Lite, our embedded database, manages, and stores data locally on the device. It has full CRUD and SQL++ query functionality, and supports all major platforms including iOS, OS X, tvOS, Android, Linux, Windows, Xamarin, Kotlin, Ionic, and more.

Learn more
Secure synchronization from the cloud to the edge

Couchbase Mobile includes a secure gateway for data sync over the web, as well as peer-to-peer sync between Couchbase Lite instances, with support for authentication, authorization, and fine-grained access control. Choose from fully managed sync with Capella App Services, or install and manage Couchbase Sync Gateway yourself.

Learn more
C-API: Support for any embedded platform or device

The C-API allows embedding Couchbase Lite on any embedded application (embedded Linux, ARM32, ARM64). Developers can use FFI to bind to C-API for any language (Dart, Rust, Python, Node.js, etc.).

Learn more
REST APIs: Full programmatic access

REST APIs provide full programmatic access for reading and writing data, as well as securely administering synchronization over the web. Input and output is JSON, and it’s easy to integrate with existing apps and REST architectures.

Learn more
JSON: Flexible data modeling

Couchbase Mobile uses JSON as its lightweight and flexible data modeling language. All data is stored and transmitted as JSON, including the embedded database, the database server, REST APIs, stream APIs, and batch APIs.

Learn more
SQL++, scopes & collections

Full SQL support means you query Couchbase Mobile just like a relational database. Scopes and collections organizes data just like schemas and tables, making queries easier, security more granular, and data sync more efficient.

Learn more
Events: Respond to changes in the database

Couchbase Mobile raises events when data changes in the database. These events can be subscribed to on both the device and server.

Cloud database

Enterprise class database in the cloud. Scale to millions of users with 24x365 uptime. Choose from a fully managed and hosted Database-as-a-Service with Couchbase Capella, or deploy and host your own Couchbase Server.

Learn more about Couchbase Capella DBaaS

Products

Couchbase Lite

Embedded NoSQL, JSON document database and alternative to SQLite with full CRUD. Built from the ground up as a native database for mobile devices and custom embedded hardware. Couchbase Lite leads all SQLite alternatives.

Learn more about Couchbase Lite
Secure synchronization

Couchbase Mobile includes a secure gateway for data synchronization over the web, with support for authentication, authorization, and fine-grained access control. Choose from fully managed sync with Capella App Services, or install and manage Couchbase Sync Gateway yourself.

Learn more about Capella app services
Cloud database

Enterprise class database in the cloud. Scale to millions of users with 24x365 uptime. Choose from a fully managed and hosted Database-as-a-Service with Couchbase Capella, or deploy and host your own Couchbase Server.

Learn more about Capella DBaaS

Platforms & Languages

Platforms

Couchbase Mobile supports all major mobile platforms in addition to traditional desktop and server environments.

Languages

Couchbase Mobile supports all major mobile programming languages.

Customer success spotlight

PepsiCo relies on Couchbase to power apps that operate even when offline, and sync in real time when connected, allowing reps in the field to service customers anywhere – regardless of internet speed or connectivity.

Learn more
Sync in real time
Service customers anywhere

Lotum uses Couchbase Mobile to provide a consistent and always-on experience for the millions of monthly active users of their most popular game title. Gamers can play wherever they go, even without internet.

Learn more
800 million game downloads
10+ million monthly active users

Doddle’s storefront package pickup and return service uses a mobile app that enables customers and employees to quickly manage transactions anytime, with or without a network connection.

Learn more
<3 months of development
100+ stores

Tommy Hilfiger transformed the buying experience for retailers by creating a powerful digital showroom that minimizes the shipment of sample garments.

Learn more
80% fewer samples produced

Use cases & solutions

Edge computing

Deploy and run secure, multi-tenant mobile applications across complex edge computing topologies to meet any speed, availability or security requirement.

Learn more
Device to device sync

Achieve real-time responsiveness and 100% uptime for offline-first applications with an embedded database and direct collaboration between edge devices.

Learn more
Field service

Enable field employees with one platform to manage data from different sources, push that data to the edge, and ensure that data is available online and offline.

Learn more
IoT data management

Manage, support, and drive real-time data insights at the edge with embedded and cloud databases, sync, and guaranteed data availability.

Learn more

Ready to create amazing customer experiences?

The easiest and fastest way to begin with Couchbase

Author