Web
React
A floating button that opens your feature board in a sheet, for any React app: Vite, Create React App, Remix or your own setup.
Needs React 18 or later.
Set up
Install the package
npm install @fewchurs/react1.7.2 is the latest version.
Using Next.js? Follow the Next.js guide instead. It keeps your key on the server.
Add your API key
Put the key in your environment file. With Vite, the name must start with
VITE_so your app can read it..env.localVITE_FEWCHURS_KEY=fr_live_xxxUsing Create React App? Name it
REACT_APP_FEWCHURS_KEYand read it withprocess.env.REACT_APP_FEWCHURS_KEY.The key ends up in your JavaScript files. That is okay: it only works from your own domain, and each device has daily limits. To hide it anyway, see If you use your own server.
Add the floating button
Wrap your app in
FewchursProviderwith your key, addFewchursButtononce, and import the styles file once.App.tsximport { FewchursButton, FewchursProvider } from "@fewchurs/react";import "@fewchurs/react/styles.css";export function App() { return ( <FewchursProvider apiKey={import.meta.env.VITE_FEWCHURS_KEY}> {/* the rest of your app */} <FewchursButton floating /> </FewchursProvider> );}A Feedback button now stays on the bottom right of every page. Pressing it slides in your feature board as a sheet, or from the bottom on phones. Inside the sheet, New request shows only the form, and Comments and Notify me open in a popup. A popup closes with its × button, Escape, or a click outside it.
The board only loads when someone presses the button.
@fewchurs/react 1.7.0 or later. To upgrade, run npm install @fewchurs/react@latest.Change the look
Pass your own label as the button's text. Use floating="left" for the bottom left, or leave out floating to place the button anywhere in your page. Every other prop goes to the board in the sheet: which tabs to show, and your colors and text. You can also use CSS variables like --fw-primary and --fw-radius. Light and dark mode follow the visitor's system setting.
<FewchursButton floating="left" tabs={["top", "new", "roadmap"]} theme={{ primary: "#0f766e", radius: 8 }}> Suggest a feature</FewchursButton>className and style go on the button itself.
Want to draw each row yourself? Use a render function, or build the board from parts:
<FewchursBoard renderFeature={(feature, actions) => ( <MyRow feature={feature} onVote={actions.toggleVote} /> )}/>// Or put the parts together yourself<FewchursBoard.Root unstyled> <FewchursBoard.Tabs /> <FewchursBoard.List /> <FewchursBoard.SubmitTrigger /></FewchursBoard.Root>unstyled removes all our styles but keeps the behavior and keyboard support.
Use a full page board
Want the board on its own page instead of in a sheet? Use FewchursBoard inside the same provider. It takes the same props as the button.
import { FewchursBoard, FewchursProvider } from "@fewchurs/react";import "@fewchurs/react/styles.css";export function App() { return ( <FewchursProvider apiKey={import.meta.env.VITE_FEWCHURS_KEY}> <FewchursBoard /> </FewchursProvider> );}<FewchursBoard theme={{ primary: "#0f766e", radius: 8 }} labels={{ title: "Ideas", submit: "Suggest an idea" }}/>Link to one request
initialFeatureId shows one request above the list, with its comments already open. Use it for a link from an email or a changelog straight to the request someone voted on. It works on FewchursButton and FewchursBoardDialog too.
// e.g. /feedback?request=abc123const requestId = new URLSearchParams(location.search).get("request");<FewchursBoard initialFeatureId={requestId ?? undefined} />If the id no longer exists, the board says "This request no longer exists." and still shows the list. To fetch one request without the board, use useFeature:
const { feature, isLoading, error, refresh } = useFeature(requestId);Signed-in users
By default each visitor gets a random ID, saved in the browser. If your app has accounts, pass a hash of the user's ID instead. Then votes follow the person to every device.
// Use a hash of your user's ID, never the raw ID or an email<FewchursProvider apiKey={import.meta.env.VITE_FEWCHURS_KEY} deviceId={hashedUserId}> {/* the rest of your app */} <FewchursButton floating /></FewchursProvider>Build your own UI
The hooks give you the data and actions with no markup. Use them inside FewchursProvider. They share one store, so a vote updates everywhere at once.
const { features, isLoading, loadMore, hasMore } = useFeatures({ sort: "top" });const { hasVoted, upvoteCount, toggle } = useVote(featureId);const { comments, add } = useComments(featureId);const { submit, isPending } = useSubmitFeature();const { isFollowing, follow, unfollow } = useFollow(featureId);const { feature } = useFeature(featureId);Handling errors
Nothing throws. When a call fails, you get an error with a code. userMessage(error) turns it into a short sentence you can show.
import { useSubmitFeature } from "@fewchurs/react";import { userMessage } from "@fewchurs/react/core";const { submit, error } = useSubmitFeature();const feature = await submit({ title, description });if (!feature && error) { showToast(userMessage(error)); // a friendly sentence for your users}| Code | What happened |
|---|---|
invalid_key | The API key is wrong or turned off, or this domain isn't added to your app. |
validation_failed | Something in the form is missing or too long. |
rate_limited | This device hit its daily limit. |
limit_reached | Your plan's limit was reached. |
not_found | That request no longer exists. |
network | No connection, or the server didn't answer. |
server | Something broke on our side. Try again. |
Localhost and going live
Your API key only works from the domain you add to your app. The visitor's browser reports the domain on every call, so there is nothing to set in your code.
While you build on localhost
You only need your API key. There is nothing to add in the dashboard yet. localhost and 127.0.0.1 always work. That also means a board that works on localhost doesn't prove your domain is set up. You can only check that on your live site.
When you go live
Open your app in the Fewchurs dashboard.
Under Where does your app run? pick Web.
Add just the domain in Website domain, like
yourcompany.com. Leave outhttps://.Click Save changes. A new domain can take up to a minute to work.
Add
VITE_FEWCHURS_KEYto the environment variables where your site is built, then deploy.Press the button on your live site. You should see your requests.
Which addresses work
If you add yourcompany.com:
| Your site runs on | Result |
|---|---|
http://localhost:5173 | Works |
https://yourcompany.com | Works |
https://www.yourcompany.com | Works |
https://app.yourcompany.com | Works |
https://othercompany.com | Refused |
https://yourapp.vercel.app | Refused |
Subdomains of the domain you add work on their own. It doesn't work the other way: if you add app.yourcompany.com then yourcompany.com is refused. Add the main domain if you use more than one.
Staging and preview sites
A browser can't change the domain it reports, so there is no setting to override it. A site on a different address, like a preview deployment, needs its own app and API key in the dashboard.
If you use your own server
To keep the key off the browser, send the board's calls to your own server instead. Your server adds the key and forwards each call to Fewchurs.
// Your server adds the API key. The browser never sees it.<FewchursProvider baseUrl="/api/fewchurs"> <FewchursButton floating /></FewchursProvider>Your server should also tell Fewchurs your domain. Add this header to each call:
X-Fewchurs-App-Id: yourcompany.comIf something goes wrong
When a call is refused, the sheet shows Invalid API key. For a domain problem, the line under it names the domain to add. For more detail, open your browser's developer tools, go to the Network tab and click the failed call:
| Status | What it means | What to do |
|---|---|---|
403 | This domain isn't added to the app for this key. The code is wrong_app. | Add the domain in the dashboard. |
401 | The key is wrong or no longer active. | Copy the key from the dashboard and deploy again. |
The "Powered by" badge
The free plan shows a small "Powered by Fewchurs" line. It goes away on its own when you upgrade to Starter or Pro.
VITE_ (or REACT_APP_), and restart your dev server after adding it. When you deploy, set it where your site is built.