Repository: remix-run/react-router
File: packages/react-router/lib/types/route-module.ts (TypeScript)

Code before:
  /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
  request: Request;
  /**
   * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
   * @example
   * // app/routes.ts
   * route("teams/:teamId", "./team.tsx"),
   *
   * // app/team.tsx
   * export function loader({
   *   params,
   * }: Route.LoaderArgs) {
   *   params.teamId;
   *   //        ^ string
   * }
   **/
  params: T["params"];
  /**
   * Without `future.unstable_middleware` enabled, this is the context passed in
   * to your server adapter's `{@link getLoadContext}` function. It's a way to bridge the
   * gap between the adapter's request/response API with your React Router app.
   * It is only applicable if you are using a custom server adapter.
   *
   * With `future.unstable_middleware` enabled, this is an instance of
   * `{@link unstable_RouterContextProvider}` and can be used for type-safe access to
   * context value set in your route middlewares.  If you are using a custom
   * server adapter, you may provide an initial set of context values from your
   * `{@link getLoadContext}` function.
   */
  context: MiddlewareEnabled extends true
    ? unstable_RouterContextProvider
    : AppLoadContext;
};

export type CreateServerMiddlewareFunction<T extends RouteInfo> = (
  args: ServerDataFunctionArgs<T>,
  next: unstable_MiddlewareNextFunction<Response>
) => MaybePromise<Response | void>;

export type CreateClientMiddlewareFunction<T extends RouteInfo> = (
  args: ClientDataFunctionArgs<T>,
  next: unstable_MiddlewareNextFunction<undefined>
) => MaybePromise<undefined>;

export type CreateServerLoaderArgs<T extends RouteInfo> =
  ServerDataFunctionArgs<T>;

export type CreateClientLoaderArgs<T extends RouteInfo> =
  ClientDataFunctionArgs<T> & {
    /** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */
    serverLoader: () => Promise<ServerDataFrom<T["module"]["loader"]>>;

Review comment (suggestion):
This wasn't working right so removing until we can figure out the right approach after the new API docs land

![Screenshot 2025-03-06 at 8 37 23 AM](https://github.com/user-attachments/assets/a6b3da71-6ace-4ae2-a3b5-cf9777fbbb9a)


Code after:
type ServerDataFunctionArgs<T extends RouteInfo> = {
  /** A {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Fetch Request instance} which you can use to read the url, method, headers (such as cookies), and request body from the request. */
  request: Request;
  /**
   * {@link https://reactrouter.com/start/framework/routing#dynamic-segments Dynamic route params} for the current route.
   * @example
   * // app/routes.ts
   * route("teams/:teamId", "./team.tsx"),
   *
   * // app/team.tsx
   * export function loader({
   *   params,
   * }: Route.LoaderArgs) {
   *   params.teamId;
   *   //        ^ string
   * }
   **/
  params: T["params"];
  /**
   * Without `future.unstable_middleware` enabled, this is the context passed in
   * to your server adapter's `getLoadContext` function. It's a way to bridge the
   * gap between the adapter's request/response API with your React Router app.
   * It is only applicable if you are using a custom server adapter.
   *
   * With `future.unstable_middleware` enabled, this is an instance of
   * `unstable_RouterContextProvider` and can be used for type-safe access to
   * context value set in your route middlewares.  If you are using a custom
   * server adapter, you may provide an initial set of context values from your
   * `getLoadContext` function.
   */
  context: MiddlewareEnabled extends true
    ? unstable_RouterContextProvider
    : AppLoadContext;
};

export type CreateServerMiddlewareFunction<T extends RouteInfo> = (
  args: ServerDataFunctionArgs<T>,
  next: unstable_MiddlewareNextFunction<Response>
) => MaybePromise<Response | void>;

export type CreateClientMiddlewareFunction<T extends RouteInfo> = (
  args: ClientDataFunctionArgs<T>,
  next: unstable_MiddlewareNextFunction<undefined>
) => MaybePromise<undefined>;

export type CreateServerLoaderArgs<T extends RouteInfo> =
  ServerDataFunctionArgs<T>;

export type CreateClientLoaderArgs<T extends RouteInfo> =
  ClientDataFunctionArgs<T> & {
    /** This is an asynchronous function to get the data from the server loader for this route. On client-side navigations, this will make a {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API fetch} call to the React Router server loader. If you opt-into running your clientLoader on hydration, then this function will return the data that was already loaded on the server (via Promise.resolve). */