SDK
Store Config Fetch store configuration using the Storefront SDK
The store resource provides methods for fetching store configuration, including business info, SEO settings, payment methods, navigation pages, campaigns, feature flags, and analytics configuration.
Fetch the complete store configuration.
const config = await storefront.store. getConfig ();
Options:
Option Type Description signalAbortSignalCancel the request cacheRequestCacheFetch cache mode next.revalidatenumber | falseNext.js ISR revalidation time in seconds next.tagsstring[]Next.js cache tags for on-demand revalidation
Returns: Promise<StoreConfig>
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
}
Property Type Description idstringStore ID namestringStore name emailstringContact email phonestringContact phone addressstringStreet address citystringCity postalCodestringPostal code countrystringCountry code (e.g., "FI") currencystringCurrency code (e.g., "EUR") currencySymbolstringCurrency symbol (e.g., "€") defaultVatRatenumberDefault VAT rate businessIdstringBusiness ID (Y-tunnus) logoUrlstring | nullStore logo URL
Property Type Description seoTitlestring | nullDefault page title seoDescriptionstring | nullDefault meta description domainstring | nullStore domain URL openGraphImageUrlstring | nullOpen Graph image ogImageAltstring | nullAlt text for Open Graph image twitterImageUrlstring | nullTwitter card image twitterHandlestring | nullTwitter/X handle instagramUrlstring | nullInstagram profile URL facebookUrlstring | nullFacebook page URL tiktokUrlstring | nullTikTok profile URL youtubeUrlstring | nullYouTube channel URL pinterestUrlstring | nullPinterest profile URL linkedinUrlstring | nullLinkedIn profile URL priceRangestring | nullPrice range indicator businessTypestring | nullBusiness type for structured data foundingDatestring | nullStore founding date (ISO 8601) googleVerificationCodestring | nullGoogle Search Console verification code
Property Type Description methodsstring[]Active payment methods (e.g., ["stripe", "paytrail"]) defaultVatRatenumberDefault VAT rate for payments
Property Type Description wishlistEnabledbooleanWishlist feature enabled guestCheckoutEnabledbooleanGuest checkout allowed newsletterEnabledbooleanNewsletter signup enabled reviewsEnabledbooleanProduct reviews enabled
Property Type Description slugstringPage URL slug titlestringPage title
Property Type Description umamiWebsiteIdstring | nullUmami website tracking ID umamiScriptUrlstring | nullURL to the Umami tracking script (only set when umamiWebsiteId exists)
Property Type Description idstringCampaign ID namestringCampaign name descriptionstring | nullCampaign description type"FREE_SHIPPING" | "BUY_X_PAY_Y"Campaign type startDatestringCampaign start date endDatestring | nullCampaign end date isActivebooleanWhether campaign is active FreeShippingCampaignobject | nullFree shipping details BuyXPayYCampaignobject | nullBuy X Pay Y details
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"]
// Cache for 5 minutes (recommended for store config)
const config = await storefront.store. getConfig ({
next: { revalidate: 300 }
});
import { cache } from 'react' ;
import { storefront } from '@/lib/storefront' ;
export const getStoreConfig = cache ( async () => {
return storefront.store. getConfig ({
next: { revalidate: 300 }
});
});
const config = await storefront.store. getConfig ();
// Find free shipping campaign
const freeShipping = config.campaigns. find (
c => c.type === 'FREE_SHIPPING'
);
if (freeShipping?.FreeShippingCampaign) {
const minSpend = freeShipping.FreeShippingCampaign.minimumSpend / 100 ;
console. log ( `Free shipping on orders over €${ minSpend }` );
}
// 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 }!` );
}
const config = await storefront.store. getConfig ();
// Add Umami tracking script to your layout
if (config.analytics.umamiWebsiteId && config.analytics.umamiScriptUrl) {
// In Next.js layout:
// <Script src={config.analytics.umamiScriptUrl}
// data-website-id={config.analytics.umamiWebsiteId} />
}
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] : [],
},
};
}
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;
}