definePlugin
Allows defining a type-safe plugin that can be used in defineIntegration
.
You can then use it in withPlugins
:
Usage
-
A plugin defines a
name
and asetup
function. -
The
setup
function accepts a name and must return an object -
The returned object is made of astro hooks and must returned an object of additional properties
Limitations
- Plugins support overrides. That means that if 2 plugins declare the same
name
, the latest will be kept.
Practical examples
Astro Integration Kit uses definePlugin
for its core plugins under the hood,
have a look at our source for practical examples!