C
CanxJS
v1.6.2
  • Learn
  • Blog
  • Showcase
C
CanxJS

Ultra-fast async MVC backend framework for Bun. Build production-ready APIs with elegance and speed.

Resources

  • Documentation
  • Learn
  • Blog
  • Showcase

Documentation

  • Introduction
  • Installation
  • Core Concepts
  • CLI Commands
  • API Reference

Legal

  • Privacy Policy
  • Terms of Service

© 2026 CanxJS. All rights reserved.

Built with ❤️ for Candra Kirana

  • WebSockets
  • Task Scheduling
  • Queues
  • Job Batches
  • Caching
  • Events
  • Broadcasting
  • Notifications
  • SMS Channels
  • File Storage
  • Payment
  • Search
  • Security
  • Security Comparison
  • Performance
  • HTTP/2 Support
  • Deployment
Networking

HTTP/2 Support

Unlock the full potential of modern networking with native HTTP/2 support, including multiplexing and server push.

Multiplexing

Multiple requests over a single TCP connection.

Server Push

Proactively send assets to the client.

Secure by Default

Native support for SSL/TLS.

Setup

Create an HTTP/2 server using the helper function. Note that SSL certificates are required.

http2-server.ts
1import { createHttp2Server } from "canxjs";
2import fs from "fs";
3
4// HTTP/2 requires SSL/TLS
5const server = createHttp2Server({
6 port: 3000,
7 key: fs.readFileSync("./cert/key.pem"),
8 cert: fs.readFileSync("./cert/cert.pem"),
9 allowHTTP1: true // Fallback to HTTP/1.1
10});
11
12server.get("/", (req, res) => {
13 return res.send("Hello form HTTP/2!");
14});
15
16server.listen();

Server Push

Push assets to the client before they are requested, reducing load times.

server-push.ts
1// Server Push Example
2server.get("/", (req, res) => {
3 // Push style.css automatically when index is requested
4 if (res.stream.pushAllowed) {
5 res.push("/style.css", {}, (err, stream) => {
6 stream.on('error', console.error);
7 stream.respond({ ':status': 200, 'content-type': 'text/css' });
8 stream.end('body { background: #000; }');
9 });
10 }
11
12 return res.html('<html><head><link rel="stylesheet" href="/style.css"></head><body><h1>HTTP/2</h1></body></html>');
13});

Next Steps

Explore more core concepts.