Skip to content

registerRoute ​

Function @vite-pwa/workbox-swkit/routing
ts
registerRoute(capture: string | RegExp | RouteMatchCallback | Route, handler?: RouteHandler, method?: HTTPMethod): Route

Easily register a RegExp, string, or function with a caching strategy to a singleton Router instance.

This method will generate a Route for you if needed and call workbox-routing.Router#registerRoute.

Parameters ​

  • capture – If the capture param is a Route, all other arguments will be ignored.

  • handler – A callback function that returns a Promise resulting in a Response. This parameter is required if capture is not a Route object.

  • method – The HTTP method to match the Route against.

Returns: The generated Route.

Released under the MIT License.