Skip to main content


Module Overview

Keywork includes React contexts that are useful for server-side rendering. These contexts are used to provide hook data to your application, such as the current request, the current location, and the current environment.

Much of the data provided by these contexts is already available to your app within your router's callback function, but you can also use these contexts to access the data within your components in a more React-like way.

::: tip Generally, you won't need to add these contexts to your application, as Keywork will automatically add them for you. :::


The EnvironmentContext provides the current request's env object to your application. This is useful when interacting with bindings attached to your Cloudflare Worker, or when you need to access environment variables from Node.js.


The URLMatchContext provides the current request's match object to your application. This is useful when you need to access a porition of request's URL, such as a slug, or a query parameter.


A a convenience hook that returns the route parameters from the current request:

import { useParams } from 'keywork/hooks'

interface PageParams {
foo: string

const MyComponent: React.FC = () => {
const params = useParams<PageParams>()

return (
<h1>My Component</h1>
<p>My slug is: {}</p>


import * as Contexts from 'keywork/hooks'