Skip to content

How can I access another plugin鈥檚 registered options inside Fastify?聽#1108

Open

Description

@inyourtime

馃挰 Question here

I have a situation where multiple plugins are registered in my Fastify app. Each plugin can receive its own options object when registered, for example:

fastify.register(require('./pluginA'), { foo: 'bar' })
fastify.register(require('./pluginB'))

In pluginB, I鈥檇 like to access the options that were passed to pluginA

Is there a built-in or recommended way to access another plugin鈥檚 options directly?

Activity

  1. metcoder95 commented on Aug 26, 2025

    @metcoder95
    Member

    The plugin should be registered with Symbol.for('skip-override') to customize the upper context instead of creating a new one. Recommend you to use fastify-plugin to wrap your plugins, includes all these settings by default

  2. inyourtime commented on Aug 26, 2025

    @inyourtime
    Author
    fastify.register(fp(require('./pluginA'), { name: "pluginA" }), { foo: 'bar' })
    
    fastify.register(fp(async function (fastify, opts) {
      // Can I access the options of pluginA here?
      // For example: { foo: 'bar' }
    }))

    Is there a way to access another plugin鈥檚 options like this?

  3. metcoder95 commented on Aug 27, 2025

    @metcoder95
    Member

    Unless the plugin exposes somehow that information, is not currently possible

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions