Fetch dictionary data with the JSS REST Dictionary Service


Example for how to fetch Sitecore dictionary data with the JSS REST Dictionary Service.

To invoke the REST Dictionary Service from a JSS application, use the JSS RestDictionaryService:


This example assumes you create the files in the root directory of the application and that you have a config.js file in that same directory. Adjust the import statements as necessary to reflect your project's setup.

To fetch dictionary data with the JSS REST Dictionary Service:

  1. In a dictionary-service.ts file, create an instance of the RestDictionaryService class and provide the configuration object:

    import { RestDictionaryService } from '@sitecore-jss/sitecore-jss';
    import config from './config';
    export const dictionaryService = new RestDictionaryService({
      apiHost: config.sitecoreApiHost,
      apiKey: config.sitecoreApiKey,
      siteName: config.jssAppName,
  2. In the file where you want to fetch the data, import and use your new dictionary service instance:

    import { dictionaryService } from './dictionary-service';
    const language = 'en';
    dictionaryService.fetchDictionaryData(language).then(data => {
        // do something with the data