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

medusa-profile-shipping

v0.1.2

Published

Profile-grouped shipping selection for Medusa v2 storefronts — one shipping method per shipping profile, so mixed carts (regulated + regular items) can actually check out

Readme

medusa-profile-shipping

Profile-grouped shipping selection for Medusa v2 storefronts.

Medusa requires one shipping method per shipping profile in the cart: core validates coverage at "Place Order", and its add-shipping-method workflow replaces same-profile methods while keeping the rest. The stock Next.js starter renders a single flat option list, so a mixed cart (a regulated item on an "FFL" profile plus a t-shirt on the default profile) can never be completed through it — the buyer picks one method, and completion rejects with "the cart items require shipping profiles that are not satisfied".

This package turns that into a per-profile selection: group the cart's items by shipping profile, show each group the options that can actually fulfill it, and require one pick per group before continuing to payment.

Zero runtime dependencies. Structurally typed (no @medusajs/* version coupling): pass any objects shaped like a Medusa cart and its shipping options. React is an optional peer, only for the /react hook.

Install

npm install medusa-profile-shipping

Data prerequisites

Fetch with these fields so the grouping has data (both are plain Medusa store-API field selections):

// cart:
"items.product.shipping_profile.id,items.product.shipping_profile.name,+shipping_methods.shipping_option_id"
// shipping options:
"+shipping_profile_id"

Helpers (framework-agnostic)

import {
  groupCartByShippingProfile,
  optionsForProfileGroup,
  selectionsFromCart,
  allGroupsCovered,
  groupKey,
} from "medusa-profile-shipping"

const groups = groupCartByShippingProfile(cart)
// [{ profileId: "sp_nfa", profileName: "NFA", itemTitles: ["Suppressor"] },
//  { profileId: "sp_default", profileName: "Other", itemTitles: ["Shirt"] }]

const nfaOptions = optionsForProfileGroup(shippingOptions, groups[0])
const selections = selectionsFromCart(cart, shippingOptions)
const readyForPayment = allGroupsCovered(groups, selections)

Missing data fails open: items without profile data form one group that sees every option, and option lists without shipping_profile_id are never filtered. Medusa's completion validation remains the backstop.

React hook (headless)

import { useProfileShipping } from "medusa-profile-shipping/react"

const { groups, optionsFor, selections, select, covered, saving, error, groupKey } =
  useProfileShipping({
    cart,
    options: shippingOptions,
    // your server action / API call; Medusa keeps other profiles' methods
    setShippingMethod: (optionId) =>
      sdk.store.cart.addShippingMethod(cart.id, { option_id: optionId }),
  })

return (
  <>
    {groups.map((group) => (
      <fieldset key={groupKey(group)}>
        {groups.length > 1 && (
          <legend>
            {group.profileName} — {group.itemTitles.join(", ")}
          </legend>
        )}
        {optionsFor(group).map((option) => (
          <label key={option.id}>
            <input
              type="radio"
              checked={selections[groupKey(group)] === option.id}
              onChange={() => select(group, option.id)}
            />
            {option.name}
          </label>
        ))}
      </fieldset>
    ))}
    <button disabled={!covered || saving}>Continue to payment</button>
  </>
)

select() is optimistic with rollback, covered gates the continue button, and single-profile carts produce one group — render it without the legend and the step looks identical to stock.

Why this isn't a Medusa (backend) plugin

There is nothing to install server-side: Medusa core already validates profile coverage at completion and manages one-method-per-profile on the cart. The entire gap is storefront UI, which backend plugins cannot ship. This package is the reusable piece of that UI logic.

License

MIT