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 🙏

© 2024 – Pkg Stats / Ryan Hefner

moltin-react

v1.0.2

Published

ReactJS SDK for the Moltin eCommerce API

Downloads

3

Readme

Moltin React.JS SDK

The Moltin React SDK is a simple to use interface for the Moltin eCommerce API to help you get off the ground quickly and efficiently within client and server applications. moltin-react is a React-friendly derivation of Moltin's js-sdk package that makes full use of React's feature set.

📚 API v1 docs — 📚 API v2 (pre-release) docs — 📚 moltin.com

Pre-Release Notice

This package is generally functional but does not currently have full code coverage. Endpoints currently available are:

API v1/v2

  • [x] Brands
  • [x] Cart
  • [x] Categories
  • [x] Collections
  • [x] Currencies
  • [x] Gateways
  • [x] Orders
  • [x] Products

API v1

  • [x] Settings
  • [x] Modifiers - available via Moltin.Products
  • [ ] Customers
  • [ ] Addresses
  • [ ] Taxes
  • [ ] Shipping
  • [ ] Promotions
  • [ ] Flows
  • [ ] Entries
  • [ ] Fields
  • [ ] Email Templates
  • [ ] Webhooks
  • [x] Images

API v2

  • [x] Files

Installation

npm install --save moltin-react

Usage

Option A: MoltinClient

import { MoltinClient } from 'moltin-react';

const Moltin = MoltinClient({
  clientId: 'XXX'
});

// Authenticate the client
Moltin.Authenticate().then((response) => {
  console.log('authenticated', response);
});

Option B: generic constructor

moltin-react exports a named object with the above MoltinClient instantiator, as well as an uninstantiated Moltin class, so the client can also be instantiated as a constructor:


import moltin from 'moltin-react'; // NOTE: unnamed import

const Moltin = new moltin({
  clientId: 'XXX'
});

// same as option A from here on out

Moltin.Authenticate().then((response) => {
  console.log('authenticated', response);
});

Note: This requires a Moltin account.

Once created, Moltin in the above example conforms to the standard Moltin JS documentation. Check out the Moltin wiki to learn more about authenticating and the available endpoints.

Configuration

On creation, either of the above options takes an identical configuration object, which requires only clientId (see Authentication) but which can accept any of the following:

FORMAT: /* <key> // [<default value>], <comment> */
{

  clientId, // required
  clientSecret, // API Secret. Don't utilize unless you're rendering on server.
  currency,
  debug, // [false]
  language, // [false]
  version // ['v1'], API version; also accepts 'v2', which, again, is currently unavailable.
}

Troubleshooting

If you're using webpack, you'll need to add the following to webpack.config.js or webpack configuration equivalent:

node: {
  fs: 'empty'
}

This is a temporary patch and will eventually be replaced with a more react-friendly alternative (see Roadmap).

Roadmap

As previously stated, moltin-react is pre-release but still usable. Here's what's coming down the pike:

  • [ ] full API v1 support
  • [ ] flux/redux integration
  • [ ] roll-your-own storage manager
  • [ ] separation of localStorage into modular storage engine
  • [ ] higher-order components

Development

The SDK is built with ES6 modules that are bundled into Node and browser compatible files using Rollup.

If you want to roll your own bundle, or make changes to any of the modules in src, then you'll need to install the package dependencies and build the dist files.

npm install
npm run build

You can learn more about Rollup, the API and configuration here.