React SDK
scrift-react is a minimal layer for React 18+ apps: one provider for your API key, a <ScriftLogo /> component, and hooks. It does not add a runtime dependency on scrift-sdk; URL building and fetch for GET /v1/svg/{slug} are included so the package stays small.
Trademark and usage: You are responsible for how logos and colours are shown. Review scrift.app/legal and each brand’s guidelines. Scrift is not affiliated with the brands in the catalogue.
Install
Coming soon. scrift-react is not published to npm yet, and this page does not give an install command until it is. It will be published as its own package, like scrift-sdk, and needs React 18+ (react, react-dom) as peers.
This page (live): docs.scrift.app/docs/sdks/react
Quick start
import { ScriftProvider, ScriftLogo } from 'scrift-react';
export function App() {
return (
<ScriftProvider apiKey={import.meta.env.VITE_SCRIFT_API_KEY}>
<ScriftLogo slug="stripe" width={48} height={48} />
</ScriftProvider>
);
}
- Mount
ScriftProvideronce at the app root (or around a subtree) with a valid API key. ScriftLogois inline by default: it fetches the SVG with your key inX-API-Keyand inlines the markup, so it works with the key fromScriftProviderand can be themed with CSS. An<img>(inline={false}) cannot send that header, so it is only for a same-origin proxy that adds the key on the server: see SVG / images and the package README.- Optional provider props:
baseUrl,timeoutMs(for inline fetches),fetch(tests or custom environments).
Hooks
useScrift()— read config from the provider (apiKey,baseUrl,timeoutMs,fetch). Does not fetch by itself. Throws ifScriftProvideris missing.useScriftLogo({ slug, variant, theme, inline }): logo state:url, optionalsvg,status,error. Inline mode issuesX-API-Keyfetches. When the slug (or variant /inlineflag) changes while a request is in flight, older responses are dropped so list UIs do not show the wrong brand.
ScriftLogo is built on useScriftLogo.
ScriftProvider and ScriftLogo (summary)
| Area | Notes |
|---|---|
ScriftProvider | Required: apiKey. Optional: baseUrl (default https://api.scrift.app), timeoutMs (default 30000 for inline), fetch. |
ScriftLogo | Required: slug. Optional: variant (none by default: the API serves the brand's best file), theme (light, dark or auto; see below), alt, width / height, className / style (no default styles in the package), inline (default true; false renders an <img>, for a same-origin proxy only), loading (skeleton, inline only), renderError (omit = silent error UI). |
Light and dark pages
theme="dark" asks for a file that can be seen on a dark page, and theme="light" for one that can be seen on a light page, on every plan. theme="auto" follows the visitor's system setting (prefers-color-scheme): with inline={false} it renders a <picture> whose dark source the browser picks on a dark system, and inline it fetches the file for the current setting and again when the setting changes. A site with its own light and dark toggle should pass light or dark from that toggle, because auto cannot see it. theme and variant together are an error, with no request.
Full prop tables, loading / error / inline theming / proxy examples, and buildScriftSvgUrl / fetchScriftSvgString will be in the package README when the package is published.
Adopting in production React apps
For dashboards, lists, or subscription UIs that re-render rows with different slugs, use ScriftProvider at the app shell and either ScriftLogo or useScriftLogo in row components. The hook is designed for slug changes while a prior request is still in flight; integration tests in the package cover a late, stale first response. Real apps (e.g. internal or partner frontends) should add scrift-react as a normal dependency and run through your usual QA — that surfaces integration gaps quickly.
License
MIT. The package carries its own LICENSE file.