Pular para o conteúdo principal

makeStarlightClient

Callable


  • Returns a new DynamicStarlightClient, which is a StarlightClient with support to create ModelInstances using the dynamic syntax. To learn which methods a client supports, see StarlightClient.

    This function accepts a StarlightConfig object and can be used to create new clients that connect to a single Starlight workspace. Each client returned by this function is separate and independent of the others.

    If you only need to make requests to a single workspace, it’s probably easier to use the SDK’s default client. To use it, you only need to import the default object exported by the SDK:

    // `Starlight` below is the default StarlightClient.
    import Starlight from '@starlightcms/js-sdk'

    See default for more info on how to use the default client.

    @example

    Creating a new client and exporting it.

    import { makeStarlightClient } from '@starlightcms/js-sdk'

    const BlogClient = makeStarlightClient({
    workspace: '123123123',
    debug: true
    })

    // Feel free to export the new client so your application can use it.
    export default BlogClient

    Type parameters

    Parameters

    • config: StarlightConfig = {}

      The client configuration object. You need to provide at least the workspace property. See StarlightConfig to view all the available options.

    Returns DynamicStarlightClient<D & WorkspaceModelDefinition>