Skip to main content

Minimal HTTP router library based on the URLPattern API in JSX.

Works with
It is unknown whether this package works with Bun
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Browsers
JSR Score
100%
Published
2 months ago (0.0.3)

@fartlabs/rtx

JSR JSR score GitHub Actions

Library of @fartlabs/jsonx components for composing @fartlabs/rt routers in JSX.

API documentation

Generated API documentation is available at https://jsr.io/@fartlabs/rtx.

Getting started

Deno

Let's learn how to get started with rtx by creating a simple router in Deno.

1. Install Deno.

2. Start a new Deno project.

deno init

3. Add @fartlabs/jsonx and @fartlabs/rtx as project dependencies.

deno add @fartlabs/jsonx @fartlabs/rtx

4. Add the following values to your deno.json(c) file.

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@fartlabs/jsonx"
  }
}

5. Add a file ending in .[j|t]sx to your project. For example, main.tsx.

import { Get, Router } from "@fartlabs/rtx";

const router = (
  <Router default={() => new Response("Not found", { status: 404 })}>
    <Get
      pattern="/"
      handle={() =>
        new Response("Hello, World!")}
    />
  </Router>
);

Deno.serve((request) => router.fetch(request));

6. Spin up your HTTP server by running the .[j|t]sx file.

deno run --allow-net main.tsx

Contribute

Style

Run deno fmt to format the code.

Run deno lint to lint the code.


Developed with ❤️ @FartLabs

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @fartlabs/rtx

Import symbol

import * as mod from "@fartlabs/rtx";

Add Package

npx jsr add @fartlabs/rtx

Import symbol

import * as mod from "@fartlabs/rtx";

Add Package

yarn dlx jsr add @fartlabs/rtx

Import symbol

import * as mod from "@fartlabs/rtx";

Add Package

pnpm dlx jsr add @fartlabs/rtx

Import symbol

import * as mod from "@fartlabs/rtx";

Add Package

bunx jsr add @fartlabs/rtx

Import symbol

import * as mod from "@fartlabs/rtx";