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

@86d-app/recently-viewed

v0.0.26

Published

Recently viewed products tracking module for 86d commerce platform

Downloads

414

Readme

@86d-app/recently-viewed

Recently viewed products tracking module for the 86d commerce platform. Records which products customers browse and surfaces them for rediscovery, improving engagement and conversion.

Features

  • Track product views for authenticated and anonymous users
  • Deduplicate repeat views within a 5-minute window
  • Merge anonymous session history into customer account on login
  • Admin dashboard with most viewed products analytics
  • Two store components: full grid and compact horizontal strip

Installation

Add "recently-viewed" to your template's config.json modules array:

{
  "modules": ["cart", "products", "recently-viewed"]
}

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | maxViewsPerCustomer | string | — | Maximum views retained per customer |

import recentlyViewed from "@86d-app/recently-viewed";

recentlyViewed({ maxViewsPerCustomer: "100" });

Store Endpoints

| Method | Path | Description | |--------|------|-------------| | POST | /recently-viewed/track | Record a product view | | GET | /recently-viewed | List recently viewed products | | POST | /recently-viewed/clear | Clear viewing history | | POST | /recently-viewed/merge | Merge session views into customer (requires auth) |

POST /recently-viewed/track

{
  "productId": "prod_123",
  "productName": "Blue T-Shirt",
  "productSlug": "blue-t-shirt",
  "productImage": "/img/blue-tshirt.jpg",
  "productPrice": 2999,
  "sessionId": "sess_abc"
}

GET /recently-viewed

Query params: sessionId, take (default 20), skip

POST /recently-viewed/merge

Transfers anonymous session views to the authenticated customer. Call this on login.

{
  "sessionId": "sess_abc"
}

Admin Endpoints

| Method | Path | Description | |--------|------|-------------| | GET | /admin/recently-viewed | List all views (filterable) | | GET | /admin/recently-viewed/popular | Most viewed products | | GET | /admin/recently-viewed/customer/:id | Views for a specific customer | | DELETE | /admin/recently-viewed/:id/delete | Delete a view record |

Controller API

interface RecentlyViewedController {
  trackView(params): Promise<ProductView>
  getRecentViews(params): Promise<ProductView[]>
  getPopularProducts(params?): Promise<PopularProduct[]>
  clearHistory(params): Promise<number>
  deleteView(id): Promise<boolean>
  listAll(params?): Promise<ProductView[]>
  countViews(params?): Promise<number>
  mergeHistory(params): Promise<number>
}

Types

interface ProductView {
  id: string
  customerId?: string
  sessionId?: string
  productId: string
  productName: string
  productSlug: string
  productImage?: string
  productPrice?: number
  viewedAt: Date
}

interface PopularProduct {
  productId: string
  productName: string
  productSlug: string
  productImage?: string
  viewCount: number
}

Store Components

RecentlyViewedGrid

Full-width grid displaying recently viewed products with images, prices, and time-ago labels. Automatically hides when no views exist.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | customerId | string | — | Customer ID for authenticated users | | sessionId | string | — | Session ID for anonymous users | | limit | number | 12 | Maximum products to display | | title | string | "Recently Viewed" | Section heading | | showClear | boolean | false | Show "Clear all" button |

Usage in MDX

<RecentlyViewedGrid customerId={customerId} />

<RecentlyViewedGrid
  sessionId={sessionId}
  limit={8}
  title="You Recently Viewed"
  showClear
/>

Place on product detail pages (below the main product), the homepage, or cart page to encourage rediscovery.

RecentlyViewedCompact

Compact horizontal scrolling strip of recently viewed products. Shows small thumbnails with names and prices. Hides when no views exist.

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | customerId | string | — | Customer ID for authenticated users | | sessionId | string | — | Session ID for anonymous users | | limit | number | 6 | Maximum products to display | | title | string | "Recently Viewed" | Section heading |

Usage in MDX

<RecentlyViewedCompact customerId={customerId} />

<RecentlyViewedCompact
  sessionId={sessionId}
  limit={4}
  title="Continue Browsing"
/>

Ideal for sidebars, footer sections, or anywhere space is limited.

Notes

  • All prices are stored in cents (not dollars)
  • The dedup window is 5 minutes — viewing the same product again within 5 minutes updates the existing record
  • Session views should be merged on login via the /recently-viewed/merge endpoint
  • The admin "Most Viewed Products" panel shows the top 10 by default