Skip to main content

Built and signed on GitHub Actions

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

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
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 Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
8 months ago (0.0.6)

@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/rtx as a project dependency.

deno add @fartlabs/rtx

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

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

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 jsr:@fartlabs/rtx

Import symbol

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

---- OR ----

Import directly with a jsr specifier

import * as rtx from "jsr:@fartlabs/rtx";

Add Package

npx jsr add @fartlabs/rtx

Import symbol

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

Add Package

yarn dlx jsr add @fartlabs/rtx

Import symbol

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

Add Package

pnpm dlx jsr add @fartlabs/rtx

Import symbol

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

Add Package

bunx jsr add @fartlabs/rtx

Import symbol

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