A configuration object for initializing a Ditto instance.

Encapsulates all the parameters required to configure a Ditto instance, including identity, connectivity, and persistence.

This API is in preview and will become the standard way to initialize Ditto instances in v5, replacing the legacy Identity-based initialization.

Constructors

Properties

The connectivity configuration for this Ditto instance.

Specifies how this instance discovers and connects to peers, including network settings and authentication options.

databaseID: string

The unique identifier for the Ditto instance.

This must be a valid UUID string. You can find the ID in the Ditto portal, or provide your own if you only need to sync with a small set of peers.

Note: "Database ID" was referred to as "App ID" in older versions of the SDK.

DEFAULT_DATABASE_ID for the default database ID used when no ID is provided.

persistenceDirectory?: string

The persistence directory used by Ditto to persist data.

This property can have three types of values:

  • Absolute path: A string with an absolute file path (e.g., /Users/joe/some/path/to/my-project.ddb)
  • Relative path: A string with a relative file path (e.g., some/path/to/my-project.ddb)
  • undefined: Uses the default persistence directory

When a relative path is set, it will be resolved relative to Ditto.DEFAULT_ROOT_DIRECTORY. When this is undefined, Ditto will use a default directory name of ditto-{id} within Ditto.DEFAULT_ROOT_DIRECTORY, where {id} is the lowercase version of the id set in this DittoConfig.

To access the final resolved absolute path after creating a Ditto instance, use Ditto.absolutePersistenceDirectory. This property will always return the effective absolute file path being used, regardless of whether you provided an absolute path, relative path, or undefined.

Note: It is not recommended to directly read from or write to this directory, as its structure and contents are managed by Ditto and may change in future versions.

Note: When Logger is enabled, logs may be written to this directory even after a Ditto instance has been deallocated. Please refer to the documentation of Logger for more information.

Accessors

  • get isFrozen(): boolean
  • Returns true if the receiver has been frozen using freeze().

    Returns boolean

  • get default(): DittoConfig
  • Returns a default DittoConfig instance with standard settings.

    This is useful as a starting point or for quickly creating a basic configuration, but for production use you should customize the configuration as needed.

    Returns DittoConfig

  • get DEFAULT_DATABASE_ID(): string
  • The default database ID, used when no database ID is provided.

    Returns string

    database_id for more information about the databaseID parameter.

Methods

  • Returns a deep copy of the receiver.

    The copy is not frozen, so it's properties can be modified.

    Warning: This does not create copies of authentication handlers referenced by the identity. Changes inside the authentication handlers will be reflected in the copy.

    Returns DittoConfig