npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@versacommerce/versacommerce-js-sdk

v0.6.0

Published

Frontend JavaScript SDK for VersaCommerce shops

Downloads

39

Readme

VersaCommerce JavaScript SDK

Frontend JavaScript SDK for VersaCommerce shops that allows you to access products, collections, pages, blogs, navigation, and carts from any website.

Purpose: AI Agent Integration

This SDK serves as the "eyes and hands" for AI agents (like Claude) that can automatically build and customize online shops.

┌─────────────────┐         ┌─────────────┐         ┌─────────────────┐
│   AI Agent      │  ───►   │   JS-SDK    │  ───►   │  VersaCommerce  │
│   (Claude)      │         │  (this lib) │         │     Shop API    │
│                 │  ◄───   │             │  ◄───   │                 │
│ "Build theme"   │  data   │ getShop()   │  JSON   │  /js-api/*.json │
│                 │         │ getProducts │         │                 │
└─────────────────┘         └─────────────┘         └─────────────────┘

The AI agent uses SDK to:

  • Read shop structure (getShop())
  • Get all products (getProducts())
  • Get collections (getCollections())
  • Get pages and navigation (getPages(), getLinklists())

Then the agent can:

  • Automatically generate themes
  • Build navigation based on real data
  • Create product pages

The SDK works in the browser (not server-side), so API endpoints must have CORS headers.

Installation

npm install @versacommerce/versacommerce-js-sdk

Or via script tag:

<script src="https://unpkg.com/@versacommerce/versacommerce-js-sdk"></script>

Quick Start

import VersaCommerce from '@versacommerce/versacommerce-js-sdk';

const client = VersaCommerce.createClient({
  shopName: 'my-shop' // subdomain of your shop
});

// Fetch a product
const product = await client.findProduct(123);
console.log(product.title, product.price);

// Add to cart
const cart = await client.getCart();
cart.addItem(product);

API Reference

Shop

client.getShop().then((shop) => {
  console.log(shop.name); // => "My Shop"
  console.log(shop.currency); // => "EUR"
  console.log(shop.productsCount); // => 15
  console.log(shop.collectionsCount); // => 9
});

Products

// Find by ID
client.findProduct(206301).then((product) => {
  console.log(product.title);
  console.log(product.price);
  product.images.forEach((image) => {
    console.log(image.resize(50, 50));
  });
});

// Find by handle (URL slug)
client.findProductByHandle('my-product').then((product) => {
  console.log(product.title);
});

Collections

// Get all collections
client.getCollections().then((collections) => {
  collections.forEach((c) => console.log(c.title));
});

// Find by ID
client.findCollection(20053).then((collection) => {
  console.log(collection.title);
  collection.products.forEach((product) => {
    console.log(product.title);
  });
});

// Find by handle
client.findCollectionByHandle('sale').then((collection) => {
  console.log(collection.title);
});

Pages

// Get all pages
client.getPages().then((pages) => {
  pages.forEach((page) => console.log(page.handle, page.title));
});

// Find page by handle
client.findPage('impressum').then((page) => {
  console.log(page.title);
  console.log(page.content); // HTML content
});

Blogs & Articles

// Get all blogs
client.getBlogs().then((blogs) => {
  blogs.forEach((blog) => console.log(blog.title));
});

// Find blog by handle
client.findBlog('news').then((blog) => {
  console.log(blog.title);
  console.log(blog.articlesCount);
});

// Find article
client.findArticle('news', 'my-article').then((article) => {
  console.log(article.title);
  console.log(article.author);
  console.log(article.publishedAt);
});

Linklists (Navigation)

// Get all navigation menus
client.getLinklists().then((linklists) => {
  linklists.forEach((nav) => console.log(nav.handle, nav.title));
});

// Find navigation by handle
client.findLinklist('main-menu').then((nav) => {
  console.log(nav.title);
  nav.rootLinks.forEach((link) => {
    console.log(link.title, link.url);
    // Nested sub-navigation
    link.children.forEach((child) => {
      console.log('  -', child.title, child.url);
    });
  });
});

Cart

// Get cart
client.getCart().then((cart) => {
  console.log(cart.totalPrice);
  cart.items.forEach((item) => console.log(item.title));
});

// Add item to cart
const product = await client.findProduct(123);
const cart = await client.getCart();
cart.addItem(product);

Caching

The SDK automatically caches fetched resources. Subsequent requests for the same resource return the cached version:

// First call fetches from server
await client.findProduct(123);

// Second call returns cached version (no network request)
await client.findProduct(123);

Contributing

See DEVELOPMENT.md for development setup and guidelines.

License

MIT - see LICENSE