0.1.1 • Published 6 months ago

react-router-durable v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Example

// /app/durable-objects.ts
import type { LoaderFunctionArgs } from "react-router";
import { DurableObject } from "cloudflare:workers";

export class SampleDurableObject extends DurableObject {
  async sampleLoader({ request }: LoaderFunctionArgs) {
    return { url: request.url };
  }
}

// /app/routes/home.tsx
import { durableLoader } from "react-router-durable";
import { SampleDurableObject } from "../durable-objects";

// Makes a react-router loader that proxies the load to the SampleDurableObject
export const loader = durableLoader(
  SampleDurableObject,
  (env) => env.sample.sampleLoader,
  "sample" // the name of the DurableObject to use
);

export default function Home() {
  const { url } = useLoaderData<typeof loader>();

  return <h1>url: {url}</h1>;
}

Installation

# NPM
$ npm install --save react-router-durable
# Yarn
$ yarn add react-router-durable
# PNPM
$ pnpm add react-router-durable
# Bun
$ bun add react-router-durable

License

Distributed under the MIT License. See LICENSE for more information.

0.1.1

6 months ago

0.1.0

6 months ago