-
Single Fetch: Improved typesafety (#9893)
If you were already using previously released unstable single-fetch types:
- Remove
"@remix-run/react/future/single-fetch.d.ts"
override fromtsconfig.json
>compilerOptions
>types
- Remove
defineLoader
,defineAction
,defineClientLoader
,defineClientAction
helpers from your route modules - Replace
UIMatch_SingleFetch
type helper withUIMatch
- Replace
MetaArgs_SingleFetch
type helper withMetaArgs
Then you are ready for the new typesafety setup:
// vite.config.ts declare module "@remix-run/server-runtime" { interface Future { unstable_singleFetch: true; // 👈 enable _types_ for single-fetch } } export default defineConfig({ plugins: [ remix({ future: { unstable_singleFetch: true, // 👈 enable single-fetch }, }), ], });
For more information, see Guides > Single Fetch in our docs.
- Remove
-
Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Single Fetch: Add a new
unstable_data()
API as a replacement forjson
/defer
when customstatus
/headers
are needed (#9769) - Add a new
replace(url, init?)
alternative toredirect(url, init?)
that performs ahistory.replaceState
instead of ahistory.pushState
on client-side navigation redirects (#9764)
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Typesafety for single-fetch:
defineLoader
,defineClientLoader
,defineAction
,defineClientAction
(#9372, #9404) - Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Deprecate
DataFunctionArgs
in favor ofLoaderFunctionArgs
/ActionFunctionArgs
(#8173)- This is aimed at keeping the types aligned across server/client loaders/actions now that
clientLoader
/clientActon
functions haveserverLoader
/serverAction
parameters which differentiateClientLoaderFunctionArgs
/ClientActionFunctionArgs
- This is aimed at keeping the types aligned across server/client loaders/actions now that
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
-
Remove
createCloudflareKVSessionStorage
(#6898) -
Drop
@cloudflare/workers-types
v2 & v3 support (#6925) -
Removed/adjusted types to prefer
unknown
overany
and to align with underlying React Router types (#7319, #7354):- Renamed the
useMatches()
return type fromRouteMatch
toUIMatch
- Renamed
LoaderArgs
/ActionArgs
toLoaderFunctionArgs
/ActionFunctionArgs
AppData
changed fromany
tounknown
Location["state"]
(useLocation.state
) changed fromany
tounknown
UIMatch["data"]
(useMatches()[i].data
) changed fromany
tounknown
UIMatch["handle"]
(useMatches()[i].handle
) changed from{ [k: string]: any }
tounknown
Fetcher["data"]
(useFetcher().data
) changed fromany
tounknown
MetaMatch.handle
(used inmeta()
) changed fromany
tounknown
AppData
/RouteHandle
are no longer exported as they are just aliases forunknown
- Renamed the
-
Require Node >=18.0.0 (#6939)
-
The route
meta
API now defaults to the new "V2 Meta" API (#6958)- Please refer to the (docs and Preparing for V2 guide for more information.
-
Removed support for "magic exports" from the
remix
package. This package can be removed from yourpackage.json
and you should update all imports to use the source@remix-run/*
packages: (#6895)- import type { ActionArgs } from "remix"; - import { json, useLoaderData } from "remix"; + import type { ActionArgs } from "@remix-run/node"; + import { json } from "@remix-run/node"; + import { useLoaderData } from "@remix-run/react";
- Export proper
ErrorResponse
type for usage alongsideisRouteErrorResponse
(#7244) - Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
-
Add
HeadersArgs
type to be consistent with loaders/actions/meta and allows for using afunction
declaration in addition to an arrow function expression (#6247)import type { HeadersArgs } from "@remix-run/node"; // or cloudflare/deno export function headers({ loaderHeaders }: HeadersArgs) { return { "x-my-custom-thing": loaderHeaders.get("x-my-custom-thing") || "fallback", }; }
-
Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- feat: support async
getLoadContext
in all adapters (#6170) - add
logDevReady
as replacement for platforms that can't initialize async I/O outside of the request response lifecycle. (#6204) - Updated dependencies:
@remix-run/[email protected]
-
We have made a few changes to the API for route module
meta
functions when using thefuture.v2_meta
flag. These changes are only breaking for users who have opted in. (#5746)V2_HtmlMetaDescriptor
has been renamed toV2_MetaDescriptor
- The
meta
function's arguments have been simplifiedparentsData
has been removed, as each route's loader data is available on thedata
property of its respectivematch
object// before export function meta({ parentsData }) { return [{ title: parentsData["routes/some-route"].title }]; } // after export function meta({ matches }) { return [ { title: matches.find((match) => match.id === "routes/some-route") .data.title, }, ]; }
- The
route
property on route matches has been removed, as relevant match data is attached directly to the match object// before export function meta({ matches }) { const rootModule = matches.find((match) => match.route.id === "root"); } // after export function meta({ matches }) { const rootModule = matches.find((match) => match.id === "root"); }
- Added support for generating
<script type='application/ld+json' />
and meta-related<link />
tags to document head via the routemeta
function when using thev2_meta
future flag
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Deprectated
createCloudflareKVSessionStorage
in favor ofcreateWorkersKVSessionStorage
(#2542)
- Updated
RequestHandler
type to match other adapter types (#4884) - Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
-
Introduces the
defer()
API from@remix-run/router
with support for server-rendering and HTTP streaming. This utility allows you to defer values returned fromloader
functions by returning promises instead of resolved values. This has been refered to as "sending a promise over the wire". (#4920)Informational Resources:
- https://gist.github.com/jacob-ebey/9bde9546c1aafaa6bc8c242054b1be26
- https://github.com/remix-run/remix/blob/main/decisions/0004-streaming-apis.md
Documentation Resources (better docs specific to Remix are in the works):
-
Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Export
V2_HtmlMetaDescriptor
andV2_MetaFunction
types from runtime packages (#4943) - Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Importing functions and types from the
remix
package is deprecated, and all (#3284) exported modules will be removed in the next major release. For more details, see the release notes for 1.4.0 where these changes were first announced.
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- We've added a new type:
SerializeFrom
. This is used to infer the (#4013) JSON-serialized return type of loaders and actions.
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
- Updated dependencies:
@remix-run/[email protected]
-
We enhanced the type signatures of
loader
/action
anduseLoaderData
/useActionData
to make it possible to infer the data type from return type of its related server function.To enable this feature, you will need to use the
LoaderArgs
type from@remix-run/cloudflare
instead of typing the function directly:- import type { LoaderFunction } from "@remix-run/cloudflare"; + import type { LoaderArgs } from "@remix-run/cloudflare"; - export const loader: LoaderFunction = async (args) => { - return json<LoaderData>(data); - } + export async function loader(args: LoaderArgs) { + return json(data); + }
Then you can infer the loader data by using
typeof loader
as the type variable inuseLoaderData
:- let data = useLoaderData() as LoaderData; + let data = useLoaderData<typeof loader>();
The API above is exactly the same for your route
action
anduseActionData
via theActionArgs
type.With this change you no longer need to manually define a
LoaderData
type (huge time and typo saver!), and we serialize all values so thatuseLoaderData
can't return types that are impossible over the network, such asDate
objects or functions. -
Updated dependencies
@remix-run/[email protected]