Javascript
This page covers some of the publicy available APIs Voyager exposes for you to use.
Notifications
Allows you to fluently display notifications in the UI.
Simple
Title and message
Timeout
Indeterminate
Confirm
Prompt
Select
Methods
Store
Voyager implements a very simple store that holds some of the most important data used throughout of Voyager. This includes BREADs, menu items, tables, formfields and much more. Check the whole store here
In your Vue components you are able to access the store as easy as:
Eventbus
Voyager fires various events and listenes to them in another place.
For example, when updating the admin.sidebar_title
setting, it will automatically update while you are typing.
To fire and listen to your own events, use the following example:
To only listen for an event (setting-updated
in this example):
Slugify
Voyager uses slugify under the hood. Check out its README to learn about its usage.
Axios
Voyager uses axios to make Ajax requests. To use axios in your own code, use:
Please read this to found out how to import axios without installing it locally.
Debounce
To use debounce simply use:
A note on Vite
Axios and Vue are exposed to the browsers window
object.
This allows you to use those plugins in your code without installing them locally and thus reducing bundle size.
In your vite.config.js
you can use the following to exclude them from being bundled:
The rest of the methods/APIs are set into Vues globalProperties
.
Last updated