smol
A tiny web server for Gleam targeting all JavaScript runtimes (Node.js, Deno, Bun, and others).
Features
- 🦄 Cross-Platform: Use it with Node.js, Deno, Bun or serverless functiosn with the same API
- 🚀 Fully Featured: First-class support for chunked responses, Server-Sent Events and WebSockets
- 🧩 Uses the platform: Built-in support for streaming files and working with JSON, uses standard Web APIs under the hood.
Installation
gleam add smol@1 gleam_javascript@1 gleam_http@4
Hello, World!
import gleam/javascript/promise
import smol
pub fn main() {
let handler = fn(request) {
let response = smol.send_string("Hello, Joe!")
promise.resolve(response)
}
smol.new(handler)
|> smol.start()
}
Runtime Adaptation
smol provides functions to adapt your Gleam handlers to different environments:
// Convert handler to standard Web Fetch API
let fetch_handler = smol.adapt(my_handler)
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.