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

@smartwithfood/js-sdk

v2.0.4

Published

[![NPM Version](https://img.shields.io/npm/v/@smartwithfood/js-sdk.svg)](https://www.npmjs.com/package/@smartwithfood/js-sdk)

Readme

SmartWithFood JS SDK

NPM Version

SmartWithFood JS SDK is designed to integrate a widget on your website or SPA

Table of Contents

Installation

npm install @smartwithfood/js-sdk

Using yarn:

yarn add @smartwithfood/js-sdk

Alternatively, you can include it in your project from our CDN. Replace {version} with the desired package version.

<script src="https://unpkg.com/@smartwithfood/js-sdk@{version}/dist/index.min.js"></script>

Usage

ESModules

import Recipe2Basket, { Language } from '@smartwithfood/js-sdk';

Recipe2Basket.initialize({
  token: '<your-widget-token>',
  language: Language.NL,
});

Recipe2Basket.renderButtons({ ... });

Browser

<script src="https://unpkg.com/@smartwithfood/js-sdk@{version}/dist/index.min.js"></script>
<script>
  window.Recipe2Basket.initialize({
    token: '<your-widget-token>',
    language: 'fr',
  });

  Recipe2Basket.renderButtons({ ... });
</script>

API

function Recipe2Basket.initialize(options: InitializeOptions)

Recipe2Basket.initialize({
  token: '<your-widget-token>',
  language: Language.NL,
});

function Recipe2Basket.openModal(options: ModalOptions)

Open the widget modal.

Recipe2Basket.openModal({
  partnerId: '00000000-0000-0000-0000-000000000000',
  recipes: [
    {
      name: 'Recept',
      language: 'nl',
      media: 'https://example.com/image.png',
      ingredients: [
        "1 ei",
        "100 g aardappelen"
      ],
      yield: 4
    }
  ]
});

function Recipe2Basket.closeModal()

Recipe2Basket.closeModal();

function Recipe2Basket.renderButtons(options: ButtonOptions): CleanupFunction

Render a button which opens the widget modal when pressed. Returns a CleanupFunction which will remove the button when called.

Recipe2Basket.renderButtons({
  type: ButtonType.SINGLE_RECIPE,
  selectorOrElement: '.r2b-button-container',
  recipes: [
    {
      name: 'Recept',
      language: 'nl',
      media: 'https://example.com/image.png',
      ingredients: [
        "1 ei",
        "100 g aardappelen"
      ],
      yield: 4
    }
  ],
});

function Recipe2Basket.getBasketUri(options: ModalOptions): String

Returns the URI which can be used in an iframe or redirect to show the widget.

Recipe2Basket.getBasketUri({
  partnerId: '00000000-0000-0000-0000-000000000000',
  recipes: [
    {
      name: 'Recept',
      language: 'nl',
      media: 'https://example.com/image.png',
      ingredients: [
        "1 ei",
        "100 g aardappelen"
      ],
      yield: 4
    }
  ]
});

function Recipe2Basket.on(name: String, callback: Function)

Each event's Data object extends the GenericEventData object.

| Name | Data | Description | | --------------- | ---------------------- | ----------- | | inited | | Widget interface is loaded and is fetching data | | loaded | | Widget interface is ready | | modalClosed | | Widget is closed | | basketCompleted | { basketId: string } | User has completed a basket |

Sample code to handle events

r2b.on('inited', function() {
  console.log('Recipe2Basket is initialized');
})

function CleanupFunction

A cleanup function which when called will remove the previously made element and modal from the DOM. This is usefull when using frameworks like React. Here is some example code on how this could be used.

import React, { useLayout } from 'react';
import Recipe2Basket from '@smartwithfood/js-sdk';

Recipe2Basket.initialize({ ... });

export function MyComponent() {
  useEffect(() => {
    const buttonCleanup = Recipe2Basket.renderButon({
      selectorOrElement: '#add-recipe-button',
      ...
    });

    return () => {
      buttonCleanup();
    }
  });

  return <div id="add-recipe-button"></div>;
}

type Recipe

A Recipe is a RecipeObject OR a String. When a string is provided we assume this is a uuid from our Recipe Management service.

object InitializeOptions

| Property | Default | Type | Description | | --------------- | --------------- | -------------------------- | ----------- | | token* | None | String | Your widget identification token | | language* | None | Language | Language of the widget |

object RecipeObject

| Property | Type | | ----------- | --------------------------- | | name | String | | language | Language | | media | String | | yield | Number | | ingredients | [String] |

object ModalOptions

| Property | Default | Type | Description | | --------------- | ---------------------- | ------------------------ | ----------- | | recipes* | None | [Recipe] | Array of recipes to add to the shoppinglist | | partnerId* | None | String | Id of the warehouse we want to productize the recipes in | | externalUrl | window.location.href | String | The url where the recipes where selected | | warehouseId | None | String | Id of the warehouse we want to productize the recipes in |

object ButtonOptions

| Property | Default | Type | Description | | ------------------ | ------------------ | -------------------------------- | ----------- | | type | single_recipe | [ButtonType] | The type of button to render | | selectorOrElement | None | String | Element | Where the button should render | | recipes* | None | [Recipe] | Array of recipes to add to the shoppinglist |

enum Language

| Property | Value | | -------- | ----- | | NL | nl | | FR | fr | | EN | en |

enum ButtonType

| Property | Value | | ------------- | ---------------- | | SINGLE_RECIPE | single_recipe |

object GenericEventData

| Property | Type | | ----------- | --------------------------- | | name | String | | id | String |