Skip to main content

Requirements

Before installing the Wacht Rust SDK, ensure you have:
  • Rust 1.70+ - The SDK requires a recent version of Rust
  • Tokio Runtime - Async runtime for Rust
  • Valid Wacht API Key - Required for authentication

Adding the Dependency

Add the SDK to your Cargo.toml file:
[dependencies]
wacht = "2.0.0"
tokio = { version = "1", features = ["full"] }

Environment Variables

The SDK can be configured using environment variables:
WACHT_API_KEY
string
required
Your Wacht API key for authentication. This will be sent as a Bearer token.
WACHT_FRONTEND_HOST
string
required
The base URL of your Wacht frontend (e.g., https://your-app.wacht.io)
WACHT_PUBLIC_SIGNING_KEY
string
Optional PEM-encoded public key for JWT verification. If not provided, the SDK will fetch it automatically from the /.well-known/jwk endpoint.

Setting Environment Variables

WACHT_API_KEY=your-api-key-here
WACHT_FRONTEND_HOST=https://your-app.wacht.io

Feature Flags

The SDK supports the following feature flags:

axum (default)

Enables Axum middleware support for JWT authentication and permission checking.
[dependencies]
wacht = { version = "2.0.0", features = ["axum"] }
This feature adds:
  • AuthLayer - JWT validation middleware
  • PermissionLayer - Permission checking middleware
  • Request extractors (RequireAuth, RequirePermission, etc.)
  • Integration with Axum 0.8+

Version Compatibility

SDK VersionRust VersionAxum VersionTokio Version
2.0.x1.70+0.8.x1.x
1.x.x1.65+0.7.x1.x

Verifying Installation

After adding the dependency, verify the installation:
# Update dependencies
cargo update

# Build your project
cargo build

# Check for any version conflicts
cargo tree -i wacht

Next Steps

Once installed, proceed to:

Troubleshooting

Common Issues

Ensure you’ve set the WACHT_API_KEY environment variable before running your application:
export WACHT_API_KEY="your-api-key"
cargo run
If you’re using Axum in your project, ensure you’re using version 0.8.x to match the SDK:
[dependencies]
axum = "0.8"
wacht = "2.0.0"
Ensure you’ve run cargo build or cargo update after adding the dependency to your Cargo.toml.