kemal v1.9.0
Kemal
Kemal is the Fast, Effective, Simple Web Framework for Crystal. It's perfect for building Web Applications and APIs with minimal code.
Why Kemal?
- π Lightning Fast: Built on Crystal, known for C-like performance
- π‘ Super Simple: Minimal code needed to get started
- π Feature Rich: Everything you need for modern web development
- π§ Flexible: Easy to extend with middleware support
Quick Start
-
First, make sure you have Crystal installed.
-
Create a new Crystal application and step into it:
crystal init app my-kemal-app
cd my-kemal-app
- Add Kemal to your app's
shard.yml:
dependencies:
kemal:
github: kemalcr/kemal
- Replace the contents of
src/my_kemal_app.crwith your first Kemal app:
require "kemal"
# Basic route - responds to GET "http://localhost:3000/"
get "/" do
"Hello World!"
end
# JSON API example
get "/api/status" do |env|
env.response.content_type = "application/json"
{"status": "ok"}.to_json
end
# WebSocket support
ws "/chat" do |socket|
socket.send "Hello from Kemal WebSocket!"
end
Kemal.run
- Install dependencies and run your application:
shards install
crystal run src/my_kemal_app.cr
- Visit http://localhost:3000 - That's it! π
Key Features
- π High-performance by default: Built on Crystal with a thin abstraction layer so you can serve a large number of requests with low latency and low memory footprint.
- π Full REST & HTTP support: Handle all HTTP verbs (GET, POST, PUT, PATCH, DELETE, etc.) with a straightforward routing DSL.
- π WebSocket & real-time: First-class WebSocket support for building chats, dashboards and other real-time experiences.
- π¦ JSON-first APIs: Native JSON handling makes building JSON APIs and microservices feel natural.
- ποΈ Static assets made easy: Serve static files (assets, uploads, SPA bundles) efficiently from the same application.
- π Template engine included: Built-in ECR template engine for serverβrendered HTML when you need it.
- π Composable middleware: Flexible middleware system to add logging, auth, rate limiting, metrics and more.
- π― Ergonomic request/response API: Simple access to params, headers, cookies and bodies via a clear context object.
- πͺ Session management: Easy session handling with kemal-session, suitable for production apps.
Philosophy
Kemal aims to be a simple, fast and reliable foundation for building production-grade web applications and APIs in Crystal.
- Simple core, powerful building blocks: The core is intentionally simple and easy to reason about. Most power comes from Crystal itself and from middleware, not from hidden magic.
- Performance as a baseline, not a feature: Crystal's native speed means high performance is the default. Kemal keeps abstractions thin so you stay close to the metal when you need to.
- Minimal assumptions, maximum flexibility: Kemal does not force a specific ORM, template engine, or project layout. You are free to choose the tools that fit your application and your team.
- Batteries within reason: Kemal ships with the essentials (routing, middleware, templates, static files, request/response helpers) while keeping advanced concerns in separate shards you can opt into as your app grows.
Kemal is designed to feel familiar if you come from popular web frameworks, while embracing Crystal's strengths and keeping your application code straightforward, maintainable, and ready for production.
Learning Resources
- π Official Documentation
- π» Example Applications
- π Kemal Guide
- π¬ Community Chat
Contributing
We love contributions! Please read our Contributing Guide to get started.
Acknowledgments
Special thanks to Manas for their work on Frank.
License
Kemal is released under the MIT License.
kemal
- 3824
- 191
- 5
- 741
- 3
- about 2 hours ago
- October 23, 2015
MIT License
Tue, 03 Feb 2026 11:17:41 GMT