nitro icon indicating copy to clipboard operation
nitro copied to clipboard

v3: defineNitroPlugin is not exported correctly

Open haikov opened this issue 1 month ago • 2 comments

Hello,

During the migration to v3 I noticed that defineNitroPlugin is not exported from any nitro/* packages in the same way as defineTask or others.

The only way I've found for importing it now is import { defineNitroPlugin } from 'nitro/~internal/runtime/plugin';, which doesn't seem right since it references ~internal.

Is there some other expected way of importing defineNitroPlugin?

haikov avatar Nov 20 '25 06:11 haikov

It is { definePlugin } from "nitro", likely it will be from "nitro/define" in next alphas.

pi0 avatar Nov 20 '25 09:11 pi0

Thank you! That works.

However I noticed that event type got lost now and it's typed as any in the example like this:

export default definePlugin((nitroApp) => {
  nitroApp.hooks.hook('request', async (event) => {  // <--- event is of a type any
  });
});

Which is interesting. The whole nitroApp.hooks is of a type any, even though if I go into node modules I see that it's typed as hooks?: HookableCore<NitroRuntimeHooks>;. Perhaps hookable is not imported correctly?

haikov avatar Nov 21 '25 07:11 haikov