ProviderSwitcher
Lists an app's swappable capabilities (data, queue, cache, storage…) with the backend each runs on, and switches backends at runtime.
Code
import { ProviderSwitcher } from "@fadymondy/nasaq/web";<ProviderSwitcher capabilities={[ { capability: "data", label: "Data", active: "postgres", options: ["postgres", "sqlite"], isDefault: true }, { capability: "queue", label: "Queue", active: "redis", options: ["redis", "nats", "database"], isDefault: false }, ]} onSelect={(capability, backend) => api.post(`/providers/${capability}`, { backend })}/>;Developer Tools · beta
Live examples and controls: ProviderSwitcher in the lab.
Install
npx shadcn@latest add https://docs.nasaqui.com/r/provider-switcher.jsonAn operator panel for apps built on swappable capabilities. Each row is one capability (data, queue, cache, storage, realtime…) with the backend it runs on, and a select to switch it. Rows on the app's configured default say Default; switched rows say Overridden. Rows pinned by config are locked.
When to use
- In an admin or developer settings page of a framework app whose drivers can change at runtime (the ToGO provider panel).
When not to use
- Plain environment variables: use
EnvList. - On/off switches for product features: use
FeatureFlags.
Import
import { ProviderSwitcher } from "@fadymondy/nasaq/web";
// inside this monorepo: "@nasaq/web"Quick start
import { ProviderSwitcher } from "@fadymondy/nasaq/web";
<ProviderSwitcher
capabilities={[
{ capability: "data", label: "Data", active: "postgres", options: ["postgres", "sqlite"], isDefault: true },
{ capability: "queue", label: "Queue", active: "redis", options: ["redis", "nats", "database"], isDefault: false },
]}
onSelect={(capability, backend) => api.post(`/providers/${capability}`, { backend })}
/>;Anatomy
div [data-slot=provider-switcher]
├─ header row (Capability · Backend), from sm up
└─ ul
└─ li [data-slot=provider-switcher-row][data-capability][aria-busy]
├─ label + Status (Default / Overridden) + description
└─ Select [data-slot=provider-switcher-select]API
ProviderSwitcher
| Prop | Type | Default | Notes |
|---|---|---|---|
capabilities | ProviderCapability[] | — | Required. One row each. An empty list shows a short message. |
onSelect | (capability, backend) => void | Promise<void> | — | Leave out for a read-only view. A returned promise keeps the row busy until it settles. |
labels | Partial<ProviderSwitcherLabels> | — | Override the built-in strings. |
Plus any <div> prop.
ProviderCapability
| Field | Type | Notes |
|---|---|---|
capability | string | The key sent to onSelect: "data", "queue". |
label / description | ReactNode | Name and one line of what it does. Default name is the key. |
active | string | The backend in use. |
options | (string | ProviderOption)[] | Backends to choose from. |
isDefault | boolean | true shows Default, false shows Overridden, unset shows nothing. |
locked | boolean | Disables the select (pinned by config). |
ProviderOption
| Field | Type | Notes |
|---|---|---|
id | string | The backend id. |
label / description | ReactNode | Menu text. |
disabled | boolean | Listed but not selectable. |
Examples
Rich options
{
capability: "data",
active: "postgres",
options: [
{ id: "postgres", label: "PostgreSQL" },
{ id: "sqlite", label: "SQLite", description: "Local file, for development" },
],
}Read-only overview
<ProviderSwitcher capabilities={capabilities} />Accessibility
- Each select is named "Backend for Data" / "مزوّد البيانات" after its row.
- A row that is applying a change has
aria-busyand its select is disabled. - Default and Overridden use
Status, which pairs a shape with the colour.
RTL & i18n
Strings ship in English and Arabic. Capability and backend names come from the host; backend ids such as postgres stay Latin.
Styling & tokens
rounded-card border-border bg-cardsurface withdivide-borderrows;text-labelnames,text-captiondescriptions.- Target a row with
[data-slot=provider-switcher-row][data-capability=queue].
Do / Don't
- Do confirm a switch server-side and return the promise, so the row shows the change only once it applied.
- Do lock capabilities that can't change without a restart.
- Don't list backends the app has no driver for.
Related
env-list, feature-flags, select, status.
Lab
https://docs.nasaqui.com/?path=/docs/components-developer-tools-provider-switcher--docs
GithubActivity
A repository activity card with a merged timeline plus commits, pull requests, workflow runs and deployments, each with status, author and a link to GitHub, filterable, with refresh, deploy and re-run callbacks.
Repository picker
Pick a GitHub repository and branch by searching through the app installation, with the official GitHub mark, debounced search, keyboard support and a Configure access link.