Vue
Embed Semaphor dashboard in your Vue app
Vue Component
This section outlines the process to render the Semaphor dashboard into your Vue app. If you don’t have a React project yet, you can set one up using Vite's guide.
1. Install Semaphor Package
Install the appropriate package based on your Vue version. Make sure the package version aligns with the Vue version listed in your package.json
2. Obtain the Auth Token
Use the following code to fetch the AuthToken
by passing your DASHBOARD_ID
and DASHBOARD_SECRET
, which you can find in the Semaphor console. In production, you will need to obtain the token from the server side.
Security Note
Do not expose DASHBOARD_SECRET
in client-side code in production. Use a
backend service to fetch the token securely.
3. Render the Dashboard
Full Code
IMPORTANT: Make sure to import vue-semaphor/dist/style.css
either at the beginning of your component or in your global CSS file. Your dashboard will not render as expected without base styles.
Below is the complete example that you can copy and paste into your application.
Nuxt
If you are using Nextjs, make sure to import the component dynamically as shown below.
Integrate as Web Component
You can also use the Web Component directly inside of your Vue project. To do that, first get the semaphor
package.
Create a wrapper component as shown below and then import that as a regular Vue component inside of your project.
Key Considerations
- Security Note: Keep the
DASHBOARD_SECRET
secure and do not expose it in client-side code in production. The examples above are for demonstration purposes. When deploying in production, obtain the authentication token from a secure, server-side environment.