Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/keywork/react/browser/functions/matchRoute.ts>PatternToPageComponentMap

A library for building V8 Isolate web apps on Cloudflare Workers, Deno, and Node.JS
Go to Latest
class PatternToPageComponentMap
extends Map<string, React.ComponentType<StaticProps>>
import { PatternToPageComponentMap } from "https://deno.land/x/keywork@v6.0.1/react/browser/functions/matchRoute.ts";

A client-side mapping of path patterns to their respective page components. This is useful if your app bundles all React route handlers into a single Worker. * A collection of patterns to their respective React components.

// Order your routes from most to least specific:
export const routeRecords = new PatternToPageComponentMap<any>([
  ['/todos/:todoSlug/:subTaskSlug/', TodoSubTaskPage],
  ['/todos/:todoSlug/', TodoPage],
  ['/todos/', TodosIndexPage],
  ['/about/', AboutPage],
  ['/privacy/', PrivacyPage],
  ['/', IndexPage],
  ['*', NotFoundErrorPage],
])

Type Parameters

StaticProps extends { }