Show Bible verses in a React app

This guide builds a reusable <Verse> component for React. It fetches a passage, shows numbered verses and adds the attribution line that translation licences require.

Uses a publishable key (bva_pk_…), because the code runs in the browser.

1. Create a publishable key

Code that runs in the browser is visible to anyone, so use a publishable key (bva_pk_). When you create it, list the websites it may run on, such as https://yourchurch.org and http://localhost:5173 for development.

2. The Verse component

This example uses Vite, which reads VITE_ variables from your .env file.

Verse.jsx
import { useEffect, useState } from "react";

const KEY = import.meta.env.VITE_BIBLE_API_KEY; // bva_pk_…

export function Verse({ reference, bible = "kjv" }) {
  const [data, setData] = useState(null);
  const [error, setError] = useState(null);

  useEffect(() => {
    const url = `https://api.bibleverse-api.com/v1/bibles/${bible}/passages?ref=${encodeURIComponent(reference)}`;
    fetch(url, { headers: { Authorization: `Bearer ${KEY}` } })
      .then(async (res) => {
        const body = await res.json();
        if (!res.ok) throw new Error(body.error.message);
        setData(body);
      })
      .catch((e) => setError(e.message));
  }, [reference, bible]);

  if (error) return <p role="alert">{error}</p>;
  if (!data) return <p>Loading…</p>;

  return (
    <figure>
      <blockquote>
        {data.passages.map((p) =>
          p.chapters.map((c) =>
            c.verses.map((v) => (
              <span key={`${p.reference}-${c.chapter}-${v.verse}`}>
                <sup>{v.verse}</sup> {v.text}{" "}
              </span>
            ))
          )
        )}
      </blockquote>
      <figcaption>{data.reference} · {data.attribution}</figcaption>
    </figure>
  );
}

3. Use it

App.jsx
import { Verse } from "./Verse";

export default function App() {
  return <Verse reference="Psalm 23:1-3" />;
}

Using Next.js or another server framework?

If the page is rendered on your server, you can call the API there with a secret key instead, and send finished HTML to the browser. Never put a secret key in code that ships to the browser; the API refuses secret keys from web pages anyway.

Ready to try it?

The Free plan gives you 5,000 requests and 2,000 verses a day, with no card.

Get a free API keyRead the API docs