-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Summary
In the new Remix 3 component API, components receive a handle object as their first argument, representing the component’s runtime interface (update scheduling, lifecycle cleanup, identity, context, etc.).
I’d like to propose:
- Renaming the public-facing parameter from
handletocomponentin examples and documentation, while keeping the underlying type name (Handle) unchanged if desired. - Optionally renaming the public type
HandletoComponentHandle(or exporting it as an alias), to make the public API more explicit (for example:export type ComponentHandle = Handle).
Current API
function Counter(handle: Handle) {
let count = 0
return () => (
<button
on={{
click: () => {
count++
handle.update()
},
}}
>
Count: {count}
</button>
)
}Proposed API (documentation & examples)
function Counter(component: Handle) {
let count = 0
return () => (
<button
on={{
click: () => {
count++
component.update()
},
}}
>
Count: {count}
</button>
)
}OR
export type ComponentHandle = Handlefunction Counter(component: ComponentHandle) {
let count = 0
return () => (
<button
on={{
click: () => {
count++
component.update()
},
}}
>
Count: {count}
</button>
)
}Motivation
The object passed as the first argument is not just a “handle” in the generic sense. Conceptually, it represents:
- the component instance
- its runtime lifecycle
- its update and scheduling capabilities
- its identity and context
Using the name component makes this immediately obvious and self-documenting.
In contrast, handle:
- is semantically vague
- feels more like an internal or systems-level term
- requires additional explanation for newcomers
Benefits of component
- Clarity: Readers instantly understand what the parameter represents.
- Improved mental model: “This object is the component at runtime.”
- Better onboarding: Reduces cognitive overhead in examples and docs.
- Future-proof: Scales naturally as the component runtime API grows.
This also aligns well with Remix’s emphasis on explicitness and readability over clever abstractions.
Benefits of ComponentHandle (Optional)
- Makes error messages and IntelliSense more explicit
- Clearly communicates what the handle refers to
- Aligns naturally with the recommended parameter name (
component) - Improves long-term API readability
Future extensibility
Using ComponentHandle also leaves room for other handle types as the system grows, for example:
RouteHandleResourceHandleServerComponentHandleBoundaryHandle
This naming pattern scales cleanly without overloading a single generic Handle type.
Again, this rename is not required to adopt the component parameter naming, but it could be a nice improvement to the public API surface.
Scope of the proposal
-
Rename the parameter in public documentation and examples.
- There is no requirement to rename:
- the underlying type (
Handle) - internal implementation details
- the underlying type (
- Existing users can still name the parameter however they like; this is about official guidance and defaults.
- There is no requirement to rename:
-
(Optional) Export
ComponentHandleas the public type name or alias.
Alternatives considered
self: elegant and expressive, but slightly more opinionated and closer to OO semantics
component strikes the best balance between explicitness, neutrality, and approachability.
Closing
This is a small naming change, but one that meaningfully improves readability and helps establish the correct mental model for the new component system early on.
Thanks for the thoughtful API design work — the direction here is really exciting.