Vue Storefront is now Alokai! Learn More
Overview

SDK

The Alokai SDK simplifies the development process by providing pre-built functionality to enables seamless interaction between your storefront and various Commerce Platforms and third-party services.

By utilizing the Alokai SDK, you can establish a type-safe contract between your storefront and various APIs with the help of the Server Middleware acting as a proxy.

Along with the Alokai SDK, we're providing tools for the State Management. Those are already preconfigured and ready to use. Available both for Next.js and Nuxt through our dedicated packages.

Key Features

  • Type-safe - The SDK is fully typed, so you can use it with confidence.
  • Plugin architecture - The SDK is built on a plugin architecture that allows you to extend its functionality with ease.
  • Modular - You can use multiple integrations at once, and they won't interfere with each other.
  • Customizable - You can extend the SDK to add new methods, modify existing methods, and more
  • Framework-agnostic - The SDK is written in TypeScript, so you can use it with any JS framework

Architecture

The SDK has two components:

  1. The SDK Core - the core package, @vue-storefront/sdk, that initializes all modules and implements the plug-in architecture
  2. Modules - pluggable pieces of code as standalone packages that integrate into the core to add functionality (eg.: middlewareModule)

In most cases, you would use middlewareModule with different configurations - but you can also create your own modules.

Example Usage

Once a module is initialized, it can be used to interact with the server middleware.

import { sdk } from '~/sdk'

await sdk.exampleModule.doSomething(); // <- fully-typed

These SDK methods will then call a corresponding middleware endpoint. This means that you don't have to worry about creating your own API calls to work a service's API. Instead, you can use the integration SDK to get the data you need.

And since the SDK is written in TypeScript, the data returned from the methods will be fully typed - meaning you can catch some errors earlier.