SDK
Store Config
Fetch store configuration using the Storefront SDK
Overview
The store resource provides methods for fetching store configuration, including business info, SEO settings, payment methods, navigation pages, campaigns, feature flags, and analytics configuration.
Methods
store.getConfig(options?)
Fetch the complete store configuration.
const config = await storefront.store.getConfig();Options:
| Option | Type | Description |
|---|---|---|
signal | AbortSignal | Cancel the request |
cache | RequestCache | Fetch cache mode |
next.revalidate | number | false | Next.js ISR revalidation time in seconds |
next.tags | string[] | Next.js cache tags for on-demand revalidation |
Returns: Promise<StoreConfig>
Response Structure
The StoreConfig object contains:
interface StoreConfig {
store: StoreInfo; // Business information
seo: StoreSeo; // SEO and social media
payments: PaymentConfig; // Payment methods
navPages: NavPage[]; // Published navigation pages
campaigns: Campaign[]; // Active campaigns
features: FeatureFlags; // Feature toggles
analytics: AnalyticsConfig; // Analytics tracking
}StoreInfo
| Property | Type | Description |
|---|---|---|
id | string | Store ID |
name | string | Store name |
email | string | Contact email |
phone | string | Contact phone |
address | string | Street address |
city | string | City |
postalCode | string | Postal code |
country | string | Country code (e.g., "FI") |
currency | string | Currency code (e.g., "EUR") |
currencySymbol | string | Currency symbol (e.g., "€") |
defaultVatRate | number | Default VAT rate |
businessId | string | Business ID (Y-tunnus) |
logoUrl | string | null | Store logo URL |
StoreSeo
| Property | Type | Description |
|---|---|---|
seoTitle | string | null | Default page title |
seoDescription | string | null | Default meta description |
domain | string | null | Store domain URL |
openGraphImageUrl | string | null | Open Graph image |
ogImageAlt | string | null | Alt text for Open Graph image |
twitterImageUrl | string | null | Twitter card image |
twitterHandle | string | null | Twitter/X handle |
instagramUrl | string | null | Instagram profile URL |
facebookUrl | string | null | Facebook page URL |
tiktokUrl | string | null | TikTok profile URL |
youtubeUrl | string | null | YouTube channel URL |
pinterestUrl | string | null | Pinterest profile URL |
linkedinUrl | string | null | LinkedIn profile URL |
priceRange | string | null | Price range indicator |
businessType | string | null | Business type for structured data |
foundingDate | string | null | Store founding date (ISO 8601) |
googleVerificationCode | string | null | Google Search Console verification code |
PaymentConfig
| Property | Type | Description |
|---|---|---|
methods | string[] | Active payment methods (e.g., ["stripe", "paytrail"]) |
defaultVatRate | number | Default VAT rate for payments |
FeatureFlags
| Property | Type | Description |
|---|---|---|
wishlistEnabled | boolean | Wishlist feature enabled |
guestCheckoutEnabled | boolean | Guest checkout allowed |
newsletterEnabled | boolean | Newsletter signup enabled |
reviewsEnabled | boolean | Product reviews enabled |
NavPage
| Property | Type | Description |
|---|---|---|
slug | string | Page URL slug |
title | string | Page title |
AnalyticsConfig
| Property | Type | Description |
|---|---|---|
umamiWebsiteId | string | null | Umami website tracking ID |
umamiScriptUrl | string | null | URL to the Umami tracking script (only set when umamiWebsiteId exists) |
gtmContainerId | string | null | Google Tag Manager container ID (e.g., "GTM-XXXXXXX") |
Campaign
| Property | Type | Description |
|---|---|---|
id | string | Campaign ID |
name | string | Campaign name |
description | string | null | Campaign description |
type | "BUY_X_PAY_Y" | Campaign type |
startDate | string | Campaign start date |
endDate | string | null | Campaign end date |
isActive | boolean | Whether campaign is active |
BuyXPayYCampaign | object | null | Buy X Pay Y details |
Free shipping is not a campaign type. Free shipping thresholds are configured per shipment method and returned with each shipping option (
freeShippingThreshold) byshipping.getOptions().
Examples
Basic Usage
import { storefront } from '@/lib/storefront';
const config = await storefront.store.getConfig();
console.log(config.store.name); // "My Store"
console.log(config.seo.seoTitle); // "My Store - Quality Products"
console.log(config.payments.methods); // ["stripe", "paytrail"]With Next.js Caching
// Cache for 5 minutes (recommended for store config)
const config = await storefront.store.getConfig({
next: { revalidate: 300 }
});Using with React Cache
import { cache } from 'react';
import { storefront } from '@/lib/storefront';
export const getStoreConfig = cache(async () => {
return storefront.store.getConfig({
next: { revalidate: 300 }
});
});Accessing Active Campaigns
const config = await storefront.store.getConfig();
// Find buy X pay Y campaign
const buyXPayY = config.campaigns.find(
c => c.type === 'BUY_X_PAY_Y'
);
if (buyXPayY?.BuyXPayYCampaign) {
const { buyQuantity, payQuantity } = buyXPayY.BuyXPayYCampaign;
console.log(`Buy ${buyQuantity}, pay for ${payQuantity}!`);
}Analytics
const config = await storefront.store.getConfig();
const { analytics } = config;
// Umami tracking
if (analytics.umamiWebsiteId && analytics.umamiScriptUrl) {
// <Script src={analytics.umamiScriptUrl}
// data-website-id={analytics.umamiWebsiteId} />
}
// Google Tag Manager
if (analytics.gtmContainerId) {
// Using @next/third-parties:
// <GoogleTagManager gtmId={analytics.gtmContainerId} />
}SEO Metadata
import { Metadata } from 'next';
import { getStoreConfig } from '@/lib/actions/storeConfigActions';
export async function generateMetadata(): Promise<Metadata> {
const config = await getStoreConfig();
return {
title: config.seo.seoTitle || config.store.name,
description: config.seo.seoDescription,
openGraph: {
images: config.seo.openGraphImageUrl ? [config.seo.openGraphImageUrl] : [],
},
};
}Error Handling
import { NotFoundError, AuthError } from '@putiikkipalvelu/storefront-sdk';
try {
const config = await storefront.store.getConfig();
} catch (error) {
if (error instanceof AuthError) {
// Invalid API key
console.error('Check your STOREFRONT_API_KEY');
}
if (error instanceof NotFoundError) {
// Store not found
console.error('Store does not exist');
}
throw error;
}