In this section, you will learn how to install the SurrealDB Mojo SDK and add it to your project.
Requirements
The only runtime dependency is Mojo itself, pinned to 0.26.1.x. The project uses pixi to manage the Mojo toolchain.
| Platform | Architecture | Status |
|---|---|---|
| macOS | arm64 | Tested |
| Linux | x86_64 | Tested |
| Linux | aarch64 | Tested |
| Windows | n/a | Use WSL2; Mojo has no native Windows toolchain |
Install the SDK
Clone the repository and install the toolchain with pixi:
To use the SDK from your own project, either vendor src/surrealdb into your Mojo package path, or build it into a .mojopkg:
Import the SDK into your project
Import the client and connection options from the surrealdb package:
For the blocking client, import SurrealClient instead:
Run your program
Run a Mojo file with the SDK source on the include path:
Build with HTTPS
The TLS code sits behind a compile-time gate, so mojo run invocations without HTTPS keep working with no OpenSSL on the system. To connect over https:// or wss://, build your program with mojo build, define the HTTPS flag, and link against libssl and libcrypto from the pixi environment:
If you use an https:// URL without -D HTTPS=1, the SDK raises a ConnectionError that names the build flags you need.
Next steps
Quickstart for a complete working example.
Connecting to SurrealDB for connection options and transports.
Authentication for signing in and managing credentials.