zio-laminar-tapir is a Scala library that integrates ZIO, Laminar, and Tapir to build reactive web applications with type-safe HTTP communication.
Live demo: 🚀 Click me for a live demo
- ZIO 2.1.20: Provides asynchronous and concurrent programming with functional effects
- Laminar 17.2.1: Scala.js library for building reactive user interfaces
- Tapir 1.11.42: Defines HTTP API endpoints as immutable data structures
- STTP 4.0.9: HTTP client implementation using Fetch API
See docs
For Sttp 3.x use version < 1.x
For Sttp 4.x use version >= 1.x
The project follows a multi-module architecture:
- core (Scala.js): Frontend client functionality with reactive UI integration
- server (JVM): Backend server endpoints and route handling
- shared (cross-platform): Common types and utilities for both frontend and backend
- examples/client: Demo application showcasing library usage
- docs: Comprehensive documentation and live demo
The BackendClient
trait provides methods to convert Tapir endpoints into ZIO effects:
def requestZIO[I, E <: Throwable, O](
endpoint: Endpoint[Unit, I, E, O, Any]
)(payload: I): Task[O]
- Automatic token management with local storage
- Session handling with expiration validation
- Secure endpoint support with token injection
Laminar's Session
trait provides reactive authentication state:
def apply[A](withoutSession: => A)(
withSession: UserToken => A
): Signal[A]
Built-in support for streaming responses with ZIO streams and WebSocket capabilities.
import dev.cheleb.ziotapir.laminar.*
// 1. Build ZIO effect from Tapir endpoint
val effect = AnEndpoints.get(1)
// 2. Run effect and emit response to event bus
effect.emit(eventBus)
- Tokens stored in localStorage by issuer URL
- Automatic expiration checking on access
- Reactive session state updates through Laminar Signals
- Token injection for secured endpoints
- Scala 3.7.2 with strict compiler options
- Scala.js for frontend compilation
- SBT build system with custom plugins for documentation
- Live demo available at the project's GitHub Pages
The library simplifies full-stack Scala development by providing a unified, type-safe approach to API communication in reactive web applications.