2-4x Faster Runtime
Pure TypeScript implementation optimized for Bun. Consistently outperforms Nunjucks in every benchmark.
2-4x Faster Runtime
Pure TypeScript implementation optimized for Bun. Consistently outperforms Nunjucks in every benchmark.
160x Faster AOT
Pre-compile templates to JavaScript functions for maximum production performance.
Multi-Engine Support
Jinja2, Handlebars, Liquid, and Twig - all through a unified API with shared filters.
84 Built-in Filters
Complete Jinja2 + Django filter set. String, number, date, list, URL, and more.
bun add binjaimport { render } from 'binja'
// Simple and fast for developmentconst html = await render('Hello, {{ name|upper }}!', { name: 'world' })// Output: Hello, WORLD!import { compile } from 'binja'
// Compile once at startupconst template = compile('<h1>{{ title }}</h1>')
// Use many times - sync and extremely fastconst html = template({ title: 'Welcome' })// Output: <h1>Welcome</h1>import { Environment } from 'binja'
const env = new Environment({ templates: './views', cache: true,})
// Render template files with inheritanceconst html = await env.render('pages/home.html', { title: 'Home', user: { name: 'John' }})| Benchmark | binja | Nunjucks | Speedup |
|---|---|---|---|
| Simple Template | 371K ops/s | 96K ops/s | 3.9x |
| Complex Template | 44K ops/s | 23K ops/s | 2.0x |
| HTML Escaping | 985K ops/s | 242K ops/s | 4.1x |
| AOT vs Nunjucks | 14.3M ops/s | 96K ops/s | 160x |
import { Hono } from 'hono'import { binja } from 'binja/hono'
const app = new Hono()app.use(binja({ root: './views' }))app.get('/', (c) => c.render('index', { title: 'Home' }))
export default appimport { Elysia } from 'elysia'import { binja } from 'binja/elysia'
const app = new Elysia() .use(binja({ root: './views' })) .get('/', ({ render }) => render('index', { title: 'Home' })) .listen(3000)| Feature | binja | Nunjucks | Pug |
|---|---|---|---|
| Jinja2 Compatible | ✅ Full | ⚠️ Partial | ❌ No |
| Django DTL Compatible | ✅ Full | ❌ No | ❌ No |
| Multi-Engine | ✅ Yes | ❌ No | ❌ No |
| AOT Compilation | ✅ Yes | ❌ No | ✅ Yes |
| Framework Adapters | ✅ Hono, Elysia | Express | Express |
| Built-in Filters | 84 | 40 | 30 |
| Debug Panel | ✅ Yes | ❌ No | ❌ No |
| AI Linting | ✅ Yes | ❌ No | ❌ No |
Installation
Get binja installed in your project in seconds.
Quick Start
Learn the basics and build your first template.