3.1.0

Options

Learn how to configure your Strapi SDK. ๐Ÿ–ฅ

url

  • Type: string
  • Default: http://localhost:1337

The URL of the Strapi server.

prefix

  • Type: string
  • Default: /api

You have the capability to modify the API endpoint prefix. The default prefix is /api, allowing you to access your API at http://localhost:1337/api.

Check out the API configuration to learn how to change the default prefix.

store

  • Type: StoreConfig
    • key
      • Type: string
      • Default: strapi_jwt
    • useLocalStorage
      • Type: boolean
      • Default: false
    • cookieOptions
      • Type: object
      • Default: { path: "/" }

The store's configuration allows you to set the key for the cookie name, as well as the localStorage key if you choose to use it thanks the useLocalStorage boolean property. Additionally, you can provide cookieOptions to be passed to the js-cookie package.

In non-browser environments, such as Node.js or SSR, cookies and localStorage are not available. In that case, the SDK stores the token in memory on the SDK instance after calling setToken. v3.0.2+

Avoid reusing the same authenticated SDK instance across multiple users or SSR requests, otherwise one user's token could be reused for another request.

import Strapi from "strapi-sdk-js"

const strapi = new Strapi({
  store: {
    key: "strapi_jwt",
    useLocalStorage: false,
    cookieOptions: { path: "/" },
  },
})

axiosOptions

  • Type: AxiosRequestConfig
  • Default: {}

Options to be passed to the Axios instance.