Plugins - add third party plugin to Nuxt
Hello,
I would like to add fast-json-patch into Nuxt as plugin. I want it to be auto-imported and avaliable globally.
I tried to add it in nuxt.config.ts as module, but it doesnt get accepted, because its not an nuxt module I believe.
In docs I only find how to create own plugins and add vue-plugins.
Any help is appreciated.
6 Replies
Hello,
Never tried to add it in the nuxt conf after installation
You can instantiate it in a util or composables
that will indeed be auto imported
Not sure it's the best way ^^, but working so far
Hi, thank you for your response. Using 'util' or 'composable' doesn't seem to be the intended method for adding plugins, does it?
Composables is basically for reusable script and is auto imported.
For exemple I have one that import zod and prepare a bunch of zobject for me, that I just check with my SchemaValidator.
Sooo it's a nice way to prepare/reuse stuff
I guess you can do something like:
That will expose all symbols in the package as auto import. To select symbols, use the
from
and imports
key in unimport https://github.com/unjs/unimportGitHub
GitHub - unjs/unimport: Unified utils for auto importing APIs in mo...
Unified utils for auto importing APIs in modules. Contribute to unjs/unimport development by creating an account on GitHub.
Thank you. I think unimport or unplugin are the way to go, as these are in nuxt integrated. I will look further into this.