
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
fastify-dynareg
Advanced tools
This package is technically a plugin builder for Fastify. It exports a single function that accepts two arguments, a package name and a boolean indicating if that package is required, and returns a valid Fastify plugin. This library can be used to define both optional or parametric plugins.
packageName <String> The plugin's package name to require().isRequired <Boolean> Defaults to false.<FastifyPlugin>In the next example, this library is used to make a plugin (fastify-blipp) optional. This behavior can be helpful for packages only used during development. If the plugin is not present, a nice debug log is written, and no errors are thrown.
const fastify = require('fastify')
const dynareg = require('fastify-dynareg')
const app = fastify()
// This plugin will try to register fastify-blipp if It's installed
const optionalBlipp = dynareg('fastify-blipp')
// You can still pass plugin options as usual
app.register(optionalBlipp, {
my: 'options'
})
app.addHook('onReady', async () => {
// Because fastify-blipp is now optional
if (app.blipp) {
app.blipp()
}
})
// TODO: Setup and start you application...
The plugin presence can also be parametric. Passing true as second argument will require the plugin presence.
const fastify = require('fastify')
const dynareg = require('fastify-dynareg')
const app = fastify()
// Force fastify-blipp presence during development
const developmentBlipp = dynareg(
'fastify-blipp',
process.env.NODE_ENV !== 'production'
)
app.register(developmentBlipp)
app.addHook('onReady', async () => {
// Because fastify-blipp is now optional
if (app.blipp) {
app.blipp()
}
})
// TODO: Setup and start you application...
In the last example, both plugin's name and presence are parametric.
const fastify = require('fastify')
const dynareg = require('fastify-dynareg')
const app = fastify()
// Declare a dynamic production plugin
const myDynamicPlugin = dynareg(
process.env.FASTIFY_PLUGIN,
process.env.NODE_ENV === 'production'
)
app.register(myDynamicPlugin, {
my: 'options'
})
// TODO: Setup and start you application...
const fastify = require('fastify')
const dynareg = require('fastify-dynareg')
const app = fastify({
logger: true
})
// Force fastify-blipp to be registered when env is not production
app.register(
dynareg(
'fastify-blipp',
process.env.NODE_ENV !== 'production'
)
)
app.get('/', async (request, reply) => {
return { hello: 'world' }
})
const start = async () => {
try {
await app.listen(3000)
// Use conditional blipp
if (app.blipp) {
app.blipp()
}
app.log.info(`server listening on ${app.server.address().port}`)
} catch (err) {
app.log.error(err)
process.exit(1)
}
}
start()
FAQs
Dynamic plugin register for Fastify
The npm package fastify-dynareg receives a total of 1 weekly downloads. As such, fastify-dynareg popularity was classified as not popular.
We found that fastify-dynareg demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.