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

Back to Learning Center
Beginner
20 min

Understanding Routing

Master the routing system and create dynamic routes.

Understanding Routing in CanxJS

CanxJS uses a Radix Tree based router, making it incredibly fast. Let's dive into defining routes.

Basic Routing

Routes are defined on the app instance:

typescript
app.get("/posts", getPosts);
app.post("/posts", createPost);
app.put("/posts/:id", updatePost);
app.delete("/posts/:id", deletePost);

Route Parameters

You can capture values from the URL using the colon syntax:

typescript
app.get("/users/:id", (req, res) => {
  const userId = req.params.id;
  return res.send(`User ID: ${userId}`);
});

Route Groups

Organize your routes using groups. This is great for APIs:

typescript
app.group("/api/v1", (router) => {
    router.get("/users", listUsers);
    router.get("/products", listProducts);
});

This creates /api/v1/users and /api/v1/products.

Have questions?

Join the discussion on GitHub