Library of @fartlabs/jsonx
components for
composing @fartlabs/rt
routers in JSX.
Generated API documentation is available at https://jsr.io/@fartlabs/rtx.
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
Run deno fmt
to format the code.
Run deno lint
to lint the code.
Developed with ❤️ @FartLabs