Home > @shopware-pwa/composables > useDefaults

# useDefaults variable

This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Returns default config depending on config key. It is used in composables, so defaultsKey is in most cases composable name (ex. useDefaults(rootContext, "useCms"))

Signature:

useDefaults: (rootContext: ApplicationVueContext, defaultsKey: string) => {
    getIncludesConfig: () => Includes;
    getAssociationsConfig: () => Association[];
    getDefaults: () => ShopwareSearchParams;
}

# Remarks

To extend defaults you need to add configuration to shopware-pwa.config.js file. Let's say we want to have a product manufacturer, media associations and listing limit on CMS pages. We need to add to configuration file:

// inside shopware-pwa.config.js

module.exports = {
  // ... other settings
  apiDefaults: {
   useCms: {
     limit: 8,
     includes: {
       product: ["manufacturer"]
     },
     associations: [
       { name: "media" }
     ]
   },
  },
}

We need to remember the structure of includes and associations. You can read more about this in shopware docs (opens new window).