Skip to main content

Extension Settings

Define configurable settings for your extension that store owners can customize from the Qumra Admin.

Defining Settings​

Settings are defined in the extension configuration. Each setting field has a type, label, and optional default value.

import type { SettingsDefinition } from "@qumra/riwaq";

const settings: SettingsDefinition = {
fields: [
{
type: "text",
key: "title",
label: "Block Title",
default: "Product Insights",
},
{
type: "number",
key: "maxItems",
label: "Max Items to Show",
default: 5,
min: 1,
max: 20,
},
{
type: "boolean",
key: "showBadge",
label: "Show Status Badge",
default: true,
},
{
type: "select",
key: "layout",
label: "Layout Style",
default: "grid",
options: [
{ label: "Grid", value: "grid" },
{ label: "List", value: "list" },
{ label: "Compact", value: "compact" },
],
},
{
type: "color",
key: "accentColor",
label: "Accent Color",
default: "#3B82F6",
},
{
type: "range",
key: "opacity",
label: "Opacity",
default: 100,
min: 0,
max: 100,
step: 5,
},
],
};

Setting Field Types​

Text​

A single-line text input.

{
type: "text",
key: "title",
label: "Title",
default: "My Extension",
}
PropertyTypeRequiredDescription
type"text"YesField type.
keystringYesUnique setting key.
labelstringYesDisplay label.
defaultstringNoDefault value.

Number​

A numeric input with optional min/max bounds.

{
type: "number",
key: "limit",
label: "Item Limit",
default: 10,
min: 1,
max: 100,
}
PropertyTypeRequiredDescription
type"number"YesField type.
keystringYesUnique setting key.
labelstringYesDisplay label.
defaultnumberNoDefault value.
minnumberNoMinimum value.
maxnumberNoMaximum value.

Boolean​

A toggle switch.

{
type: "boolean",
key: "enabled",
label: "Enable Feature",
default: false,
}

Select​

A dropdown with predefined options.

{
type: "select",
key: "theme",
label: "Theme",
default: "light",
options: [
{ label: "Light", value: "light" },
{ label: "Dark", value: "dark" },
],
}
PropertyTypeRequiredDescription
options{ label: string; value: string }[]YesAvailable choices.

Color​

A color picker.

{
type: "color",
key: "bgColor",
label: "Background Color",
default: "#FFFFFF",
}

Range​

A slider with min, max, and step.

{
type: "range",
key: "fontSize",
label: "Font Size",
default: 16,
min: 10,
max: 32,
step: 2,
}
PropertyTypeRequiredDescription
minnumberYesMinimum value.
maxnumberYesMaximum value.
stepnumberNoStep increment. Default: 1.

Accessing Settings​

Use the useSettings() hook to read settings values in your extension:

import { useSettings } from "@qumra/riwaq";

function MyExtension() {
const settings = useSettings();

return (
<div style={{ color: settings.accentColor as string }}>
<h3>{settings.title as string}</h3>
{settings.showBadge && <span>Active</span>}
</div>
);
}

Metafields​

Extensions can also define metafields for storing custom data:

import type { MetafieldDefinition } from "@qumra/riwaq";

const metafields: MetafieldDefinition[] = [
{
namespace: "my-app",
key: "product-score",
type: "number_integer",
},
{
namespace: "my-app",
key: "notes",
type: "multi_line_text",
},
];

Metafield Types​

TypeDescription
single_line_textSingle line text string.
multi_line_textMulti-line text.
number_integerInteger number.
number_decimalDecimal number.
booleanTrue/false value.
jsonJSON data.
urlURL string.