Feedback button in a Vue app
Load the script once in Vite and wrap the popup in a Vue 3 component that cleans up on unmount.
Free for one project and 100 votes. Paid plans start with a 14 day trial, no card.
Why a component
VoteFirst.suggest takes a selector or an element, and it binds to what it finds when you call it. Vue creates and removes buttons on its own schedule.
The popup attaches to a button that has to exist at that moment.
So the binding belongs in the component that owns the button.
Call the function before Vue has drawn the button and a selector matches nothing, so the click does nothing and no error appears. Call it again on every screen change and the old listeners pile up, which is how one click ends up opening two dialogs.
A component fixes both. It binds once the button is on screen, and it removes the binding when the button leaves, whether the user navigated away or a v-if switched the button off.
Load the script
A Vite project keeps its page in index.html at the root. Add the VoteFirst tag to the head, with your slug and key as data attributes.
Put the script tag in index.html, above the app entry.
A classic script loads before a module script runs.
Module scripts wait until the page has been parsed, while a classic script stops the parser and runs at once. The VoteFirst tag is classic, so window.VoteFirst exists before main.js starts Vue, and the component needs no code that waits for it.
Copy the slug and key from the Share and Embed screen of your project. The key is public by design, since all it allows is opening the form and taking votes from an allowed origin.
<head>
<script src="https://app.votefirst.app/embed/votefirst.js" data-project="your-slug" data-key="your-key"></script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>The component
A template ref gives the component the real button. onMounted passes it to VoteFirst.suggest and onBeforeUnmount calls destroy on the result.
Bind on mount and destroy before unmount.
destroy removes the click listener and closes an open dialog.
onMounted runs after the component's elements are in the page, so button.value is the live element at that point. A string selector would also work here, but the element is exact and cannot match another button by accident.
During development, hot reloading replaces components without a page refresh. The destroy call in onBeforeUnmount keeps each replaced copy from leaving a listener behind.
<script setup>
import { onBeforeUnmount, onMounted, ref } from 'vue';
const button = ref(null);
let popup = null;
onMounted(() => {
popup = window.VoteFirst.suggest({ trigger: button.value });
});
onBeforeUnmount(() => popup?.destroy());
</script>
<template>
<button ref="button" type="button">Feedback</button>
</template>Where it goes
A button in App.vue is always there, so it binds once. A button inside a routed view binds each time that view appears.
Mount one button in the layout, or one on each screen that needs it.
Both are safe, because the cleanup runs either way.
The layout choice suits a small app, since every screen then has one way to send an idea. A routed view suits an app where feedback means something different on each screen, such as a button beside an empty state or under an error.
Give the button its normal styles from your own design, and add a label that says what it does. Feedback is clear, and Send an idea is clearer when the app already has a help menu.
The board
The popup sends an idea. The board shows every idea with its status and its votes, and a user can vote there without an account.
Add a link to the public board next to the button.
New suggestions wait for your approval.
A plain anchor with the board address does the job, and the address can be your own subdomain on the Free and Pro plans. Users who open the board find their idea, and others, already counted.
Merge two cards that say the same thing and the votes of both stay on the card you keep. A user who voted on both is counted once.
If it fails
Open the page source and look for the tag with its two data attributes. Then read the console for a message from VoteFirst.
Work from the script tag to the console.
origin_not_allowed means the address is not on the key's list.
List every address you use on Share and Embed, including the one for local work, or the form refuses to load while you build. A copy of your snippet on any other address is refused too, which is the point of the list.
A TypeError that says VoteFirst is undefined means the script tag is missing, blocked by an extension, or placed after the module script. Move it into the head of index.html and reload.
What a Vue app gains
A button that behaves
It binds when it shows and lets go when it leaves, so no listeners pile up.
Ideas that add up
A board counts repeats as votes on one card, so the list shows what users want most.
One file to ship
The script is hosted by VoteFirst, so the bundle gains nothing.
Add it in five steps
One tag in the page and one component are the whole install.
Create a project
Make a project on the Free plan, then note its slug and its key.
Add the tag
Place the script in the head of index.html, above the app entry.
Add the component
Create FeedbackButton.vue with onMounted and onBeforeUnmount.
Mount it
Render the component in App.vue or in the screen that needs it.
Allow the origins
List your live address and your local one on Share and Embed.
Testing route changes
Switch between two routes in the running app and press the button once after each switch. If one press opens two dialogs, the popup was bound twice, so check that the cleanup runs on unmount.
Test with the dev server and again with the built output, since the origin list must carry both addresses.
What to know before you set this up
- This guide follows embed script version 2.8.1, so confirm any option in your dashboard if a newer release ships.
- The tag has to load before your app starts, so keep it a classic script in the head.
- Only listed origins may open the form, including your local one.
- On the Free plan the cap is 100 votes, and a vote taken back does not free its slot.
What Vue developers ask
Does this work with the Options API?
Yes. Use the mounted and beforeUnmount hooks, and read the button from this.$refs.
Can a selector replace the element?
A selector works if the button is in the page when the call runs. Inside a component that is true in onMounted, but the element cannot match something else by accident.
Why is the script in index.html and not imported?
VoteFirst is a single hosted file read through a script tag, so there is nothing to install or import. A classic tag in the head loads before the module that starts Vue.
What does destroy do?
It takes the click listener off the button and shuts the dialog if one is open. Leave it out and the old listener stays on the button.
Does the key need to be secret?
No. It is public by design and only lets a page open the form and take votes from the origins on its list.
Do users need an account to vote?
No. Anyone can vote on a new board, and the visitor's browser storage marks a return visit. If each vote must name a person, turn on required sign in.
Can the board run on my own domain?
Yes, on the Free and Pro plans. A subdomain such as feedback.yourapp.com can point at the board.
How do new suggestions reach me?
Each waits as a card in your dashboard until you approve it. Expect at most one email a day about the new ones.
Does the button work in a Capacitor or Tauri shell?
The component is plain web code, so it runs wherever the app renders in a web view. Add that origin to the key's list.
What does it cost to try?
Free gives you one project and 100 votes. The paid plans are Lite at $9/mo and Pro at $39/mo, each free for 14 days with no card.
More ways to add a board
More on React, buttons and the public roadmap.
Feature voting in a React app
The same client in any React project.
A button for any website
Every option the popup takes.
Make a public roadmap
Show users what comes next.
Add a feedback button to a Mintlify docs site
One script file and one stylesheet on every docs page.
Add a feedback button to an Angular app
Load the tag in index.html, bind after the view.
Let users tell you what to build
Begin on Free with one project and 100 votes, or try Lite or Pro for 14 days with no card.