Fetch dictionary data with the JSS REST Dictionary Service

Current version: 22.0

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


This example assumes you create the files in the /src directory of the project, and that you have a config.js file or config.ts file in the /src/temp 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 new 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 'temp/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

Do you have some feedback for us?

If you have suggestions for improving this article,