Skip to content

createStorageRoutes

const createStorageRoutes: (options) => RouteConfigEntry[] = storageRoutes

Defined in: packages/storage/src/plugin.ts:100

Backwards-friendly alias — the task description mentions createStorageRoutes by name, so we export the same function under both spellings to avoid surprising users.

Build the React Router route-config entries that mount the /uploads/* proxy + upload endpoint. The returned array is meant to be spread into the user’s routes.ts default export.

The single splat route dispatches on HTTP method inside the handler file:

  • GET /uploads/<key> — streams the R2 object at key, optionally gated by a signed token or an ownerCheck function.
  • POST /uploads/<filetype> — uploads a multipart file for the named filetype, returning { key, url }.

StorageRoutesOptions

Handler file location and (optional) base path.

RouteConfigEntry[]

One or more RouteConfigEntry objects.