remix 3.0.0-rc.3 → 3.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/INDEX.md +7 -0
  2. package/dist/fetch-router.d.ts +1 -3
  3. package/dist/fetch-router.d.ts.map +1 -1
  4. package/dist/fetch-router.js +0 -1
  5. package/dist/index.d.ts +18 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +1 -0
  8. package/guides/01-start-here.md +4 -5
  9. package/guides/02-routing-and-controllers.md +3 -3
  10. package/guides/03-request-handling.md +5 -19
  11. package/guides/04-rendering-ui.md +505 -7
  12. package/guides/05-interactivity.md +93 -6
  13. package/guides/06-streaming-ui-with-frames.md +1 -1
  14. package/guides/07-animation.md +686 -6
  15. package/guides/08-data-and-validation.md +56 -0
  16. package/guides/09-forms-and-mutations.md +52 -0
  17. package/guides/10-auth-sessions-security.md +61 -0
  18. package/guides/11-files-and-assets.md +98 -0
  19. package/guides/12-errors-and-cancellation.md +44 -0
  20. package/guides/13-testing.md +5 -5
  21. package/guides/14-cli-and-tooling.md +52 -0
  22. package/guides/15-production.md +57 -0
  23. package/package.json +58 -45
  24. package/src/assets/README.md +118 -12
  25. package/src/async-context-middleware/README.md +6 -6
  26. package/src/auth/README.md +8 -6
  27. package/src/auth-middleware/README.md +7 -7
  28. package/src/cli/README.md +2 -0
  29. package/src/compression-middleware/README.md +4 -4
  30. package/src/cookie/README.md +3 -3
  31. package/src/cop-middleware/README.md +4 -4
  32. package/src/cors-middleware/README.md +3 -3
  33. package/src/csrf-middleware/README.md +20 -12
  34. package/src/data-table/README.md +4 -4
  35. package/src/data-table-mysql/README.md +5 -5
  36. package/src/data-table-postgres/README.md +5 -5
  37. package/src/data-table-sqlite/README.md +5 -5
  38. package/src/fetch-proxy/README.md +22 -4
  39. package/src/fetch-router/README.md +17 -15
  40. package/src/fetch-router.ts +1 -3
  41. package/src/file-storage/README.md +3 -3
  42. package/src/file-storage-s3/README.md +3 -3
  43. package/src/form-data-middleware/README.md +8 -5
  44. package/src/form-data-parser/README.md +10 -8
  45. package/src/fs/README.md +4 -4
  46. package/src/headers/README.md +8 -2
  47. package/src/html-template/README.md +1 -1
  48. package/src/index.ts +18 -0
  49. package/src/lazy-file/README.md +2 -2
  50. package/src/logger-middleware/README.md +1 -1
  51. package/src/method-override-middleware/README.md +3 -3
  52. package/src/multipart-parser/README.md +26 -5
  53. package/src/multiple-import-maps-polyfill/README.md +2 -2
  54. package/src/node-fetch-server/README.md +3 -1
  55. package/src/node-hmr/README.md +16 -7
  56. package/src/render-middleware/README.md +5 -5
  57. package/src/response/README.md +6 -6
  58. package/src/route-pattern/README.md +2 -0
  59. package/src/session/README.md +4 -4
  60. package/src/session-middleware/README.md +3 -3
  61. package/src/session-storage-memcache/README.md +3 -3
  62. package/src/session-storage-redis/README.md +1 -1
  63. package/src/spa/README.md +3 -3
  64. package/src/static-middleware/README.md +15 -3
  65. package/src/tar-parser/README.md +1 -1
  66. package/src/terminal/README.md +2 -2
  67. package/src/test/README.md +14 -4
  68. package/src/ui/README.md +36 -8
  69. package/src/ui/anchor/README.md +8 -8
  70. package/src/ui/animation/README.md +2 -0
  71. package/src/ui-hmr/README.md +4 -4
package/INDEX.md CHANGED
@@ -13,7 +13,14 @@ Search this generated index by task, export name, or description. Use the guides
13
13
  | [Interactivity](guides/05-interactivity.md) | How server-rendered UI hydrates, handles events, connects components to application models, navigates, and cancels stale work. |
14
14
  | [Streaming UI with Frames](guides/06-streaming-ui-with-frames.md) | How to stream and reload route-owned UI with Frame, fallbacks, and server and browser frame resolvers. |
15
15
  | [Animation](guides/07-animation.md) | The CSS-first animation model and Remix UI helpers for motion that respects rendering state. |
16
+ | [Data and Validation](guides/08-data-and-validation.md) | How Remix validates inputs, defines relational data, queries databases, and runs SQL migrations. |
17
+ | [Forms and Mutations](guides/09-forms-and-mutations.md) | How native forms, action responses, validation failures, redirects, and enhanced mutations fit together. |
18
+ | [Auth, Sessions, and Security](guides/10-auth-sessions-security.md) | How Remix stores per-browser state, resolves identity, protects routes, and defends browser request boundaries. |
19
+ | [Files and Assets](guides/11-files-and-assets.md) | How Remix serves static files and source assets, accepts bounded uploads, stores files, and returns HTTP file responses. |
20
+ | [Errors and Cancellation](guides/12-errors-and-cancellation.md) | How expected HTTP failures, uncaught server errors, rendering failures, client runtime errors, and aborted work propagate through Remix. |
16
21
  | [Testing](guides/13-testing.md) | How to choose a test boundary and test Remix routes, stateful request flows, components, and end-to-end behavior. |
22
+ | [CLI and Tooling](guides/14-cli-and-tooling.md) | The Remix command-line workflow for creating, inspecting, testing, checking, and running TypeScript projects. |
23
+ | [Production](guides/15-production.md) | How to configure, start, cache, observe, and shut down a Remix application in production. |
17
24
 
18
25
  ## Package APIs
19
26
 
@@ -1,7 +1,5 @@
1
+ import type { RouterTypes as RemixRouterTypes } from './index.ts';
1
2
  export * from '@remix-run/fetch-router';
2
- export interface RouterTypes {
3
- }
4
- type RemixRouterTypes = RouterTypes;
5
3
  declare module '@remix-run/fetch-router' {
6
4
  interface RouterTypes extends RemixRouterTypes {
7
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-router.d.ts","sourceRoot":"","sources":["../src/fetch-router.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAA;AAEvC,MAAM,WAAW,WAAW;CAAG;AAC/B,KAAK,gBAAgB,GAAG,WAAW,CAAA;AAEnC,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,WAAY,SAAQ,gBAAgB;KAAG;CAClD"}
1
+ {"version":3,"file":"fetch-router.d.ts","sourceRoot":"","sources":["../src/fetch-router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACjE,cAAc,yBAAyB,CAAA;AAEvC,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,WAAY,SAAQ,gBAAgB;KAAG;CAClD"}
@@ -1,2 +1 @@
1
- // IMPORTANT: This file is auto-generated, please do not edit manually.
2
1
  export * from '@remix-run/fetch-router';
@@ -0,0 +1,18 @@
1
+ // IMPORTANT: This file is auto-generated, please do not edit manually.
2
+ /**
3
+ * Ambient router type configuration for application-wide defaults.
4
+ *
5
+ * Apps may augment this interface to define the default request context used by
6
+ * `createAction()`, `createController()`, and `getContext()`.
7
+ * Apps with multiple routers should pass explicit context types instead.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * declare module 'remix' {
12
+ * interface RouterTypes {
13
+ * context: AppContext
14
+ * }
15
+ * }
16
+ * ```
17
+ */
18
+ export interface RouterTypes {}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,WAAW;CAAG"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -13,7 +13,7 @@ These APIs ship together through focused subpath imports from the `remix` packag
13
13
 
14
14
  The design of Remix comes from six core principles:
15
15
 
16
- 1. **Agent-First Development.** Remix optimizes source code, documentation, tooling, and abstractions for LLMs, and provides primitives for using models inside the products you build.
16
+ 1. **Model-First Development.** Remix optimizes source code, documentation, tooling, and abstractions for LLMs, and provides primitives for using models inside the products you build.
17
17
  2. **Build on Web APIs.** Remix builds on `Request`, `Response`, `URL`, `FormData`, headers, cookies, and JavaScript because shared platform APIs reduce context switching across the full stack while keeping your application portable.
18
18
  3. **Religiously Runtime.** Remix APIs do not depend on bundlers, type generation, or static analysis. Routes, middleware, controllers, and tests should run as ordinary runtime code.
19
19
  4. **Avoid Dependencies.** Remix chooses dependencies carefully, wraps them behind its own boundaries, and works toward replacing them with focused packages when the framework needs long-term control.
@@ -78,6 +78,7 @@ my-remix-app/
78
78
  ├── router.ts # middleware, routes, and controller mapping
79
79
  ├── middleware/ # request middleware and context providers
80
80
  ├── actions/ # controllers, route actions, and route-local UI
81
+ │ ├── controller.tsx # root route controller
81
82
  │ ├── document.tsx # app document shell
82
83
  │ └── public/
83
84
  │ └── entry.ts # starts the browser runtime
@@ -93,9 +94,7 @@ import { createRequestListener } from "remix/node-fetch-server";
93
94
 
94
95
  import { router } from "./app/router.ts";
95
96
 
96
- const requestListener = createRequestListener(async (request) => {
97
- return await router.fetch(request);
98
- });
97
+ const requestListener = createRequestListener(router.fetch);
99
98
  const server = http.createServer(requestListener);
100
99
 
101
100
  server.listen(44100, () => {
@@ -549,7 +548,7 @@ export const router = createRouter({
549
548
 
550
549
  export type AppContext = RouterContext<typeof router>;
551
550
 
552
- declare module "remix/router" {
551
+ declare module "remix" {
553
552
  interface RouterTypes {
554
553
  context: AppContext;
555
554
  }
@@ -46,7 +46,7 @@ Path variables are one part of Remix's route pattern syntax. Patterns can also i
46
46
  // matches /docs/v2/guides/routing/route-maps.html?preview=1
47
47
  ```
48
48
 
49
- You do not need to memorize Remix's route pattern syntax to follow this guide. The [`route-pattern` overview](https://api.remix.run/api/remix/route-pattern/overview/) covers the full grammar and the lower-level `remix/route-pattern/href` and `remix/route-pattern/match` APIs.
49
+ You do not need to memorize Remix's route pattern syntax to follow this guide. The [`route-pattern` overview](../src/route-pattern/README.md) covers the full grammar and the lower-level `remix/route-pattern/href` and `remix/route-pattern/match` APIs.
50
50
 
51
51
  Finally, the `edit` branch has two leaves at the same URL: `index` handles `GET` and `action` handles `POST`.
52
52
 
@@ -148,7 +148,7 @@ export const routes = route({
148
148
  // routes.albums.create -> POST /albums
149
149
  ```
150
150
 
151
- These helpers produce ordinary route maps and leaves, so you can nest them with hand-written definitions. Pass a map to `createController(...)`, then register it with `router.map(...)` just as you would a hand-written map. The [`remix/router` overview](https://api.remix.run/api/remix/router/overview/) covers the full route builder API.
151
+ These helpers produce ordinary route maps and leaves, so you can nest them with hand-written definitions. Pass a map to `createController(...)`, then register it with `router.map(...)` just as you would a hand-written map. The [`remix/router` overview](../src/fetch-router/README.md) covers the full route builder API.
152
152
 
153
153
  ## Controllers and actions
154
154
 
@@ -226,7 +226,7 @@ return context.render(<AlbumPage album={album} />);
226
226
 
227
227
  The result is still an ordinary Web `Response`. An action can render a page, return text or JSON, redirect the browser, send a file, or return an error response.
228
228
 
229
- Expected outcomes such as invalid input, conflicts, and missing records should also return a `Response` with the appropriate status. Reserve thrown errors for unexpected failures. If an action or middleware throws, `router.fetch(...)` rejects so the server boundary can log the error and return a `500` response. The [Errors and Error Boundaries](/errors-and-error-boundaries/) chapter covers that path in detail.
229
+ Expected outcomes such as invalid input, conflicts, and missing records should also return a `Response` with the appropriate status. Reserve thrown errors for unexpected failures. If an action or middleware throws, `router.fetch(...)` rejects so the server boundary can log the error and return a `500` response. The [Errors and Cancellation](/errors-and-cancellation/) chapter covers that path in detail.
230
230
 
231
231
  A text response can be as simple as:
232
232
 
@@ -50,19 +50,7 @@ import { router } from "./app/router.ts";
50
50
 
51
51
  const port = process.env.PORT ? Number.parseInt(process.env.PORT, 10) : 44100;
52
52
 
53
- const server = http.createServer(
54
- createRequestListener(async (request) => {
55
- try {
56
- return await router.fetch(request);
57
- } catch (error) {
58
- if (!(request.signal.aborted && error === request.signal.reason)) {
59
- console.error(error);
60
- }
61
-
62
- return new Response("Internal Server Error", { status: 500 });
63
- }
64
- }),
65
- );
53
+ const server = http.createServer(createRequestListener(router.fetch));
66
54
 
67
55
  server.listen(port, () => {
68
56
  console.log(`Server listening on http://localhost:${port}`);
@@ -83,7 +71,7 @@ Keep that boundary narrow. Code that only needs a URL, headers, cookies, a body,
83
71
  - passes the request to your Fetch handler; and
84
72
  - writes the returned response status, headers, and streamed body through Node.
85
73
 
86
- The same listener works with `node:http`, `node:https`, and Node's HTTP/2 compatibility API. Most apps only need to pass `router.fetch(...)` through a small error boundary, as shown above. `createRequestListener(...)` also has a default error handler, but handling router errors in `server.ts` lets the app decide what to log and return.
74
+ The same listener works with `node:http`, `node:https`, and Node's HTTP/2 compatibility API. `createRequestListener(...)` logs errors and returns a generic `500` response by default.
87
75
 
88
76
  The listener accepts a few options when the server boundary needs more information:
89
77
 
@@ -97,7 +85,7 @@ The listener accepts a few options when the server boundary needs more informati
97
85
  For example, a Node server behind a trusted reverse proxy can let the listener recover the public protocol and host:
98
86
 
99
87
  ```ts filename=server.ts
100
- const requestListener = createRequestListener((request) => router.fetch(request), {
88
+ const requestListener = createRequestListener(router.fetch, {
101
89
  trustProxy: true,
102
90
  onError(error) {
103
91
  console.error(error);
@@ -143,9 +131,7 @@ Deno uses the handler in `Deno.serve(...)`:
143
131
  ```ts filename=server.ts
144
132
  import { router } from "./app/router.ts";
145
133
 
146
- Deno.serve({ port: 44100 }, (request) => {
147
- return router.fetch(request);
148
- });
134
+ Deno.serve({ port: 44100 }, router.fetch);
149
135
  ```
150
136
 
151
137
  A Cloudflare Worker exports an object with a `fetch` method:
@@ -233,7 +219,7 @@ export const router = createRouter({
233
219
 
234
220
  export type AppContext = RouterContext<typeof router>;
235
221
 
236
- declare module "remix/router" {
222
+ declare module "remix" {
237
223
  interface RouterTypes {
238
224
  context: AppContext;
239
225
  }