DEV Community

Cover image for 2. Create a Commerce.js instance - Create a Commerce.js store with Svelte
Jamie Barton for Commerce.js

Posted on

1 2

2. Create a Commerce.js instance - Create a Commerce.js store with Svelte

Before we begin writing any code, let's first create an instance of Commerce.js we can share around our application to fetch products, categories, and merchant information.



Inside your terminal, install @chec/commerce.js:

npm install -E @chec/commerce.js
Enter fullscreen mode Exit fullscreen mode

Now, inside src, create a new directory lib, and add the file commerce.js. We'll follow the Commerce.js docs on instantiating the SDK, and export it as client.

// src/lib/commerce.js
import CommerceSDK from "@chec/commerce.js";

const client = new CommerceSDK(
  "..." // Insert your Commerce.js Public API Key
);

export default client;
Enter fullscreen mode Exit fullscreen mode

If you don't want to create an account with Commerce.js to follow along with this tutorial, you can use the demo store public key pk_184625ed86f36703d7d233bcf6d519a4f9398f20048ec.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay