Skip to main content

usePostPresets

Location: src/hooks/usePostPresets.js

Overview

Fetches the list of post presets from the post_presets Supabase table, ordered by sort_order. Post presets provide pre-configured formatting or layout templates that users can apply when creating a new post. This hook is read-only and fetches once on mount.

Signature

function usePostPresets(): {
presets: PostPresetRow[],
loading: boolean
}

Parameters

None.

Return Value

PropertyTypeDescription
presetsPostPresetRow[]Array of preset rows from the post_presets table, sorted by sort_order. Empty array if none exist or if the fetch fails.
loadingbooleantrue while the initial fetch is in progress.

Usage

function PresetPicker({ onSelect }) {
const { presets, loading } = usePostPresets();

if (loading) return <Skeleton />;

return (
<div className="preset-list">
{presets.map(preset => (
<button key={preset.id} onClick={() => onSelect(preset)}>
{preset.name}
</button>
))}
</div>
);
}

Last updated: 2026-02-07