Skip to content

Repository files navigation


Cossack framework logo



The Borderless TypeScript Framework

A full-stack TypeScript framework for building real-time, edge first web applications.

Write client and server logic in the same class seamlessly, like no border exists, deploy to Cloudflare Workers or any Node compatible runtime in seconds.

Think of it like Laravel + Next.js + Phoenix LiveView, but TypeScript native and edge deployment ready.

Status

Cossack is in alpha stage. Breaking changes are expected. Do not use in production yet.

Quick Start

npx cossack create my-app
cd my-app
pnpm install
pnpm dev

The CLI will prompt you to choose a runtime adapter:

  • Cloudflare Workers (default) — edge deployment with Durable Objects for stateful WebSocket connections
  • Node.js — traditional server deployment via @hono/node-server

Why Cossack?

Cossack is the most advanced TypeScript framework for building modern web applications on any platform.

No more fetch(), no more query libraries, no more client-server boilerplate, even no more client-server components. Your server methods are directly callable from the client, and vice-versa.

import { Cossack, Page, State } from '@cossackframework/core';
import { html } from '@cossackframework/renderer';

@Page()
export default class Counter extends Cossack {
    @State() count = 0;

    increment() {
        // This runs secured on the server. 
        // The code is never exposed to the client
        this.count++;
    }

    render() {
        return html`
            <p>Count: ${this.count}</p>
            <button @click=${this.increment}>+</button>
        `;
    }
}

Key Features

Cossack has a rich set of features that every modern web application needs, plus maximum Developer Experience (DX) and performance optimizations out of the box.

  • Borderless: Secured client-server, server-client direct method calls
  • File based routing: with nested layouts
  • Server-side rendering (SSR): for first load performance and SEO
  • Soft navigation: with pre-fetching on hover, View Transitions API support
  • Real-time support: out of the box with SSE, WebSockets or Cloudflare Durable Objects
  • Optimistic UI: for instant client feedback
  • Loading UI and error handling: baked in
  • Built-in validation: with decorators
  • Automatic code security: server-only code is stripped from client bundles
  • Smart re-rendering: only re-render the parts of the page that changed
  • Markdown pages: that support layouts and frontmatter
  • Static site generation (SSG): for pre-rendering pages at build time
  • Runtime adapters: for Cloudflare Workers, Node.js, or any other serverless platform
  • Authentication: built-in with session management
  • R2 or S3 file storage integration
  • Enterprise ready: using Middleware, Service classes, and Dependency Injection (DI) for complex applications
  • Dev tools: Ctrl+Click to jump to component definition, hot reload, and more
  • Customizing headers, scripts, and meta tags: for SEO and social sharing
  • Image optimization: with automatic resizing and format conversion
  • Tailwind support
  • Latest Vite 8 and Hono version
  • First class Cloudflare Workers support
  • LLM friendly: use less tokens, native TypeScript syntax, easy for LLMs to understand, type check, and generate code
  • and a lot more features to discover in the documentation.

Real-time support

Traditional frameworks rely on a single transport mode, usually HTTP. So in order to build real-time applications, you usually have to write WebSocket client and server code yourself. Cossack supports multiple transport modes, allowing you to choose the best one for each component. You can even mix and match transport modes in the same application. For example, you can use SSE for a live feed, WebSockets for a chat, and HTTP for a form submission.

Learning Cossack

Full documentation is available in the Cossack Documentation.:

Contributing

This is a pnpm monorepo. To get started:

pnpm install
# Build all packages, use --filter to build a single package
pnpm run build

# Run the `framework` package, which includes demo pages and a dev server
pnpm run dev

Running Tests

## Unit tests
pnpm run test:unit

## E2E tests
pnpm run test:e2e

Credits

Cossack cannot exist without the following open source projects:

  • Vite (For bundling, HMR, and dev server)
  • Hono (For routing, middleware)
  • Lit (Cossack renderer is heavily inspired by Lit)
  • TypeScript (For type safety and DX)
  • Cloudflare Workers (For edge deployment and Durable Objects)

License

MIT

About

A full-stack TypeScript framework for building edge first, real-time web applications, LLM friendly.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages