Skip to content

docs(hooks): clarify how each application hook exposes Fastify instance#6557

Open
mitre88 wants to merge 1 commit intofastify:mainfrom
mitre88:codex/issue-4967-hook-instance-docs
Open

docs(hooks): clarify how each application hook exposes Fastify instance#6557
mitre88 wants to merge 1 commit intofastify:mainfrom
mitre88:codex/issue-4967-hook-instance-docs

Conversation

@mitre88
Copy link

@mitre88 mitre88 commented Mar 5, 2026

Summary

  • adds a dedicated section in docs/Reference/Hooks.md describing how each application hook exposes the Fastify instance
  • clarifies which hooks use this and which expose instance as a parameter
  • adds an explicit note about arrow functions not binding this

Related issue

resolves #4967

Checklist

| `onRoute` | via `this` (if using a `function` handler) |
| `onRegister` | via the `instance` parameter |

> **Note:** Arrow functions do not bind `this`. Use a `function` handler when you need the Fastify instance from `this`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to be a note, section is incredibly small as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ApplicationHooks have inconsistent reference to instance

2 participants