shopify_storefront_sdk
v1.0.4
Published
A fully typed Node.js + TypeScript SDK for the Shopify Storefront GraphQL API.
Maintainers
Readme
📦 Shopify Storefront SDK (Node.js + TypeScript)
A fully typed, lightweight, and developer-friendly Node.js SDK for the Shopify Storefront GraphQL API.
Built with TypeScript, GraphQL Codegen, and graphql-request — designed to help developers move faster when building Shopify headless storefronts.
✔ Fully typed queries & responses
✔ Simple, intuitive API
✔ Pre-built operations (Products, Carts, Customers, Blogs, Articles…)
✔ Works with Node.js, Next.js, Remix, Cloudflare Workers & more
✔ Supports custom GraphQL queries
✔ Automatic code generation
🔧 Installation
npm install shopify-storefront-sdk
# or
yarn add shopify-storefront-sdk
# or
pnpm add shopify-storefront-sdk
🚀 Quick Start
import { ShopifyStorefront } from "shopify-storefront-sdk";
const shopify = new ShopifyStorefront({
domain: process.env.SHOPIFY_STORE_DOMAIN!,
token: process.env.SHOPIFY_STOREFRONT_TOKEN!,
});
// Fetch a product
const product = await shopify.getProductById(
"gid://shopify/Product/1234567890"
);
console.log(product.title);📘 Features
Typed SDK methods:
- Products (ID, handle, collections)
- Recommendations
- Blogs & articles
- Carts (create/get/update)
- Customers (create, login, recovery flow)
GraphQL Codegen built in
Consistent error handling
Supports custom queries
Zero heavy dependencies
🧩 SDK API Overview
Initialize Client
const shopify = new ShopifyStorefront({
domain: "yourstore.myshopify.com",
token: "your-storefront-access-token",
});Products
Get product by ID
await shopify.getProductById(productId);Get product by handle
await shopify.getProductByHandle("my-product");Recommendations
await shopify.getProductRecommendations(productId);Carts
Create a cart
await shopify.createCart({
lines: [{ merchandiseId: "...", quantity: 1 }],
});Get cart
await shopify.getCart(cartId);Customers
await shopify.createCustomer({ email, password });
await shopify.sendResetEmail(email);
await shopify.verifyToken(token);Blogs & Articles
await shopify.getBlog("news", 10);📁 Project Structure
/src
/queries → .graphql operations
/generated → Auto-generated code
index.ts → SDK export
/codegen.yml → Codegen config
/schema.graphql → Shopify schema🛠 Development Setup
git clone https://github.com/YOUR_USERNAME/shopify-storefront-sdk.git
cd shopify-storefront-sdk
npm installCreate a .env file:
SHOPIFY_STORE_DOMAIN=yourstore.myshopify.com
SHOPIFY_STOREFRONT_TOKEN=xxxx🔨 Build
npm run buildOutputs:
dist/index.js
dist/index.cjs
dist/index.d.ts🧪 Testing
npm run dev
# after build:
npm run test🧬 Code Generation
Regenerate types & operations:
npm run generateScans:
src/queries/*.graphql
schema.graphqlGenerates:
src/generated/🌐 Requirements
- Node.js 18+
- Storefront API token
- Public or development Shopify store
🤝 Contributing
Pull requests are welcome!
- Fork the repo
- Create a branch:
git checkout -b feature/my-feature - Commit & push
- Submit a PR
📜 License
MIT License — free for commercial and personal use.
⭐ Support
If this SDK saves you time, please star ⭐ the repository— it helps others discover it and motivates future improvements!
If you want, I can also generate:
✅ Better badges (npm version, downloads, license, TypeScript)
✅ CONTRIBUTING.md
✅ API documentation table
✅ Full GitHub project template (issues, PR templates, workflows)