#useApi
API allows for plugins to register their own APIs and make them available globally.
However, they are limited to either server-side or client-side.
This reduces the complexity to import functions from other plugins, or export functions for other plugins.
#How to Declare an API
- Ensure you have an API setup in your plugin.
- Create a global declaration for your API.
- Done
#How to Get an API
This is all that's necessary to start working with other plugin APIs.
If you do not want to worry about load order. Consider the following pattern:
- Using a sperate api.ts
#How to put the API into a seperate file
If you want to write your API in a separate file like an 'api.ts' then you have to import it in your index.ts because only the 'index.ts' is loaded by default. You can then use the API in any other plugin