Skip to content
/ rtx Public

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

Notifications You must be signed in to change notification settings

FartLabs/rtx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published