Enjoying the docs? Start building free, no credit card needed. Get started →
Docs / React

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

  1. Install the package

    npm install @fewchurs/react

    1.7.2 is the latest version.

    Using Next.js? Follow the Next.js guide instead. It keeps your key on the server.

  2. 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.local
    VITE_FEWCHURS_KEY=fr_live_xxx

    Using Create React App? Name it REACT_APP_FEWCHURS_KEY and read it with process.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.

  3. Add the floating button

    Wrap your app in FewchursProvider with your key, add FewchursButton once, and import the styles file once.

    App.tsx
    import { 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.

The sheet as described here needs @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.

Open the sheet from your own button

Want to open the sheet from a menu item or a button you already have? Use FewchursBoardDialog. It takes every board prop, plus open and onClose. Escape closes it, and focus returns to the button that opened it.

FeedbackButton.tsx
import { useState } from "react";import { FewchursBoardDialog, FewchursProvider } from "@fewchurs/react";import "@fewchurs/react/styles.css";export function FeedbackButton() {  const [open, setOpen] = useState(false);  return (    <FewchursProvider apiKey={import.meta.env.VITE_FEWCHURS_KEY}>      <button onClick={() => setOpen(true)}>Feedback</button>      <FewchursBoardDialog variant="sheet" open={open} onClose={() => setOpen(false)} />    </FewchursProvider>  );}

Leave out variant="sheet" to show the board in a dialog in the middle of the screen instead.

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.

FeedbackPage.tsx
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.

App.tsx
// 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>
Always hash the ID. Never send a raw user ID or an email address.

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}
CodeWhat happened
invalid_keyThe API key is wrong or turned off, or this domain isn't added to your app.
validation_failedSomething in the form is missing or too long.
rate_limitedThis device hit its daily limit.
limit_reachedYour plan's limit was reached.
not_foundThat request no longer exists.
networkNo connection, or the server didn't answer.
serverSomething 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

  1. Open your app in the Fewchurs dashboard.

  2. Under Where does your app run? pick Web.

  3. Add just the domain in Website domain, like yourcompany.com. Leave out https://.

  4. Click Save changes. A new domain can take up to a minute to work.

  5. Add VITE_FEWCHURS_KEY to the environment variables where your site is built, then deploy.

  6. Press the button on your live site. You should see your requests.

Don't skip the domain. The sheet can work on localhost and still be refused on your live site if your domain isn't added.

Which addresses work

If you add yourcompany.com:

Your site runs onResult
http://localhost:5173Works
https://yourcompany.comWorks
https://www.yourcompany.comWorks
https://app.yourcompany.comWorks
https://othercompany.comRefused
https://yourapp.vercel.appRefused

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.com

If 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:

StatusWhat it meansWhat to do
403This domain isn't added to the app for this key. The code is wrong_app.Add the domain in the dashboard.
401The 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.

Stuck? If the sheet says "Fewchurs isn't set up", the API key is missing. Check that the variable starts with VITE_ (or REACT_APP_), and restart your dev server after adding it. When you deploy, set it where your site is built.