Skip to content

Restructure hooks docs #16337

Description

@Rich-Harris

Describe the problem

The naming around hooks files is a bit weird:

  • hooks.server.ts contains server and 'shared' hooks
  • hooks.client.ts contains client and 'shared' hooks
  • hooks.ts contains 'universal' hooks

'Shared' doesn't mean shared, it means that the hooks in question (init and handleError) can have two separate implementations for server and client. The 'universal' hooks (reroute and transport) are, however, shared.

Describe the proposed solution

Not for nothing, this is more aesthetically appealing:

hooks.client.ts
hooks.server.ts
hooks.shared.ts

hooks.shared.ts would contain what are today called 'universal' hooks but which are actually shared between server and client.

Docs-wise I would get rid of the 'Server hooks', 'Shared hooks' and 'Universal hooks' headings in favour of the hooks themselves, each of which would have something like this right after the heading:

## handle

> [!NOTE] Declared in `hooks.server.ts`
## init

> [!NOTE] Declared in `hooks.server.ts` and `hooks.client.ts`
## reroute

> [!NOTE] Declared in `hooks.shared.ts`

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions