4.2. Using Tozti’s JS api¶
4.2.1. Defining routes on the client side¶
If you read Getting Started you learned how to define new API endpoints. But you might want that your extension also provide some endpoints on the client, to display a special page for example.
You can take a look at how the extension vue-counter of the sample-extensions
repository uses this mechanism to define a counter reachable on <tozti>/counter
.
Tozti’s extensions are using vue, so it is natural that we use vue-router
in order
to define new routes.
Imagine you want to define a new ‘page’ displaying a component called Calendar
that
can be accessed on <tozti>/mycalendar
. Then, you must add the following lines in your
index.js
:
tozti.addRoutes([
{ path: '/mycalendar', component: Calendar }
])