@qwik.dev/router@2.0.0-beta.37
Breaking Changes📦 qwikView on GitHub →
⚠ 4 breaking✨ 6 features🐛 6 fixes🔧 4 symbols
Summary
This release overhauls RouteLoaders to use AsyncSignals, improving cacheability and introducing options like expiry and eTag support. Breaking changes include modifications to loader failure detection and the removal of action state access from loaders.
⚠️ Breaking Changes
- Route loaders are now AsyncSignals. Reading `value.failed` to check for loader failure is deprecated; instead, check if reading `value` throws an error, as the error is stored in the `error` property.
- `routeLoader$` can no longer read action state to ensure cacheability and predictability. Use alternative methods like reading the action signal directly in the component or deriving state from URL parameters.
- Qwik Router no longer retrieves `q-data.json` on every SPA navigation. Remove any caching rules targeting these files.
- The signature for `cacheKey` functions has changed from `(status: number, eTag: string, pathname: string)` to `(requestEv: RequestEvent, eTag: string)`.
Migration Steps
- Update route loader failure checking logic from checking `value.failed` to catching errors when reading `value`.
- Refactor any usage of `routeLoader$` reading action state to use component signals or URL-derived state.
- Remove custom caching rules for `q-data.json` files.
- Update custom `cacheKey` functions to accept `(requestEv: RequestEvent, eTag: string)`.
✨ New Features
- Route loaders now support `expires`, `poll`, and `allowStale` options.
- Route loaders now accept an `eTag` option to shortcut data retrieval if data hasn't changed.
- Route loaders now support a `cacheKey` property, similar to SSR `pageConfig`, allowing cached entries to generate an ETag before the initial request.
- When `routeConfig` provides a `cacheKey` but no `eTag`, SSR now hashes the rendered output to determine an ETag value.
- Route loaders now accept a `search` option to specify which query parameters trigger a loader run, preventing re-runs on unrelated search parameter changes.
- The `qwikRouter` option `strictLoaders` (defaulting to `true`) ensures loaders do not receive search parameters unless explicitly configured via the `search` option.
🐛 Bug Fixes
- Route loaders now redirect within their JSON response instead of using HTTP redirects.
- Route loader metadata is updated in the dev route trie when route source files change.
- Q-loader requests are now run through the full page middleware chain, correctly handling unfollowed HTTP redirects.
- Fixed fetching of non-serialized route loader data after resume.
- Middleware defined in index.* files is no longer run for a routeloader on the same path, unless the routeloader is defined in index.
- Fixed "assignment to constant variable" errors when route loaders cached filtered search state across SPA navigations.