2.3.2

Options

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

url

  • Type: string
  • Default: process.env.STRAPI_URL || http://localhost:1337

The URL of the Strapi server. You can use the STRAPI_URL environment variable to override the url.

Since v2.1.4process.env.STRAPI_URL is no longer used by default.

prefix

  • Type: string
  • Default: /api

In Strapi v4, 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.

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.