Welcome to Revali Client! This guide will help you set up everything you need to generate type-safe client code for your Revali Server.
Quick Start#
The fastest way to get started is to add both required dependencies at once:
# Add runtime dependency
dart pub add revali_client
# Add code generator
dart pub add revali_client_gen --dev
# Get all dependencies
dart pub get
That's it! You're ready to generate your client code.
Understanding the Dependencies#
Revali Client consists of two main packages that work together to generate and run your client code:
📦 Revali Client (Runtime)#
The runtime package that your generated client code depends on.
dart pub add revali_client
What it provides:
RevaliClient- The underlying HTTP clientStorage- Cookie and session storage interfacesHttpInterceptor- Request/response interceptionServerException- Standardized error handlingHttpRequest/HttpResponse- HTTP primitives
Why it's needed: This package contains the core runtime classes that the generated client uses to make HTTP requests, handle responses, and manage state.
⚙️ Revali Client Gen (Code Generator)#
The code generator that creates your client implementation during the build process.
dart pub add revali_client_gen --dev
What it provides:
- Analyzes your Revali Server routes
- Generates type-safe data source interfaces
- Creates concrete HTTP client implementations
- Handles serialization and deserialization
- Manages the generated package structure
Why it's needed: This is a build-time dependency that runs during revali dev
or revali build to generate the actual client code from your server definitions.
Manual Installation#
If you prefer to add dependencies manually, update your pubspec.yaml file:
dependencies:
revali_client: ^<latest-version> # Runtime package
dev_dependencies:
revali_client_gen: ^<latest-version> # Code generator
Configuration#
After installation, you need to enable Revali Client in your revali.yaml configuration file:
constructs:
- name: revali_client
options:
package_name: client # Optional: customize package name
server_name: Server # Optional: customize server class name
Directory Structure#
Once installed and configured, Revali Client will generate code in the following structure:
your_project/
├── .revali/
│ └── revali_client/ # Generated client package
│ ├── lib/
│ │ ├── client.dart
│ │ ├── interfaces.dart
│ │ └── src/
│ └── pubspec.yaml
├── lib/
├── routes/ # Your server routes
└── pubspec.yaml
The generated client in .revali/revali_client/ is a complete Dart package that you can import and use in your application.
Common Issues#
Generated Code Not Updating#
If the client isn't regenerating:
- Ensure
revali_client_genis indev_dependencies - Check that
revali.yamlhas the client construct enabled - Try running
revali buildorrevali devagain
What's Next?#
Now that you have Revali Client installed, you're ready to:
- Configure - Set up client generation options
- Generate Client Code - Understand the generated structure
- Use HTTP Interceptors - Add request/response handling
- Set Up Storage - Manage cookies and sessions
Ready to configure your client? Let's move on to configuration!