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

@sukooru/core

v0.2.2

Published

Framework-agnostic scroll restoration core for browser apps.

Downloads

446

Readme

@sukooru/core

Framework-agnostic scroll restoration core for browser apps.

Install

npm install @sukooru/core

Agent Skill

npx skills add https://github.com/jglee96/sukooru --skill sukooru-integration

Use the repo skill when you want an AI coding agent to choose the right Sukooru package and wire full-window or element restoration correctly.

When To Use This Package

Use @sukooru/core when you want full control over routing integration in a vanilla app or you are building your own adapter on top of Sukooru.

Restore The Full Window Scroll Position

import { createSukooru } from '@sukooru/core'

const sukooru = createSukooru({
  getKey: () => window.location.pathname,
})

const stop = sukooru.mount()
window.history.scrollRestoration = 'manual'

export const mountProductsPage = async () => {
  const handle = sukooru.registerContainer(window, 'window')
  const scrollKey = '/products'

  const status = await sukooru.restore(scrollKey)
  console.log('restore status:', status)

  return async () => {
    await sukooru.save(scrollKey)
    handle.unregister()
  }
}

// Later, when your app shuts down:
// stop()

Leave containerId as window when the browser viewport itself is the thing that scrolls.

Restore A Specific Element

import { createSukooru } from '@sukooru/core'

const sukooru = createSukooru({
  getKey: () => window.location.pathname,
})

const stop = sukooru.mount()

export const mountProductsPanel = async () => {
  const container = document.querySelector<HTMLElement>('#product-list')

  if (!container) {
    throw new Error('Missing #product-list')
  }

  const handle = sukooru.registerContainer(container, 'product-list')
  const scrollKey = '/products'

  await sukooru.restore(scrollKey)

  return async () => {
    await sukooru.save(scrollKey)
    handle.unregister()
  }
}

// Later, when your app shuts down:
// stop()

Use a stable containerId for every scrollable element that should keep its own position.

Advanced: Restore Custom List State Before Scroll

import { createSukooru } from '@sukooru/core'

const sukooru = createSukooru({
  getKey: () => window.location.pathname,
})

export const mountInfiniteProducts = async () => {
  const container = document.querySelector<HTMLElement>('#product-list')

  if (!container) {
    throw new Error('Missing #product-list')
  }

  const stateHandle = sukooru.setScrollStateHandler('product-list', {
    captureState: () => ({
      loadedPageCount,
    }),
    applyState: async (state) => {
      await loadPages(state.loadedPageCount)
    },
  })

  const containerHandle = sukooru.registerContainer(container, 'product-list')
  const scrollKey = '/products'

  await sukooru.restore(scrollKey)

  return async () => {
    await sukooru.save(scrollKey)
    containerHandle.unregister()
    stateHandle.unregister()
  }
}

ScrollStateHandler lets you restore list data first, then apply scroll after the DOM is ready again.

Use A Custom Storage Adapter

storage accepts any adapter that implements get, set, delete, and keys. Each method may return either a plain value or a promise, so both sync backends like localStorage and async backends like IndexedDB wrappers are supported.

import { createSukooru, type StorageAdapter } from '@sukooru/core'

const localStorageAdapter: StorageAdapter = {
  get: (key) => window.localStorage.getItem(key),
  set: (key, value) => {
    window.localStorage.setItem(key, value)
  },
  delete: (key) => {
    window.localStorage.removeItem(key)
  },
  keys: () => Object.keys(window.localStorage),
}

const sukooru = createSukooru({
  getKey: () => window.location.pathname,
  storage: localStorageAdapter,
})
import { createSukooru, type StorageAdapter } from '@sukooru/core'

const indexedDbLikeAdapter: StorageAdapter = {
  get: async (key) => await db.get('scroll-state', key),
  set: async (key, value) => {
    await db.put('scroll-state', value, key)
  },
  delete: async (key) => {
    await db.delete('scroll-state', key)
  },
  keys: async () => await db.getAllKeys('scroll-state'),
}

const sukooru = createSukooru({
  getKey: () => window.location.pathname,
  storage: indexedDbLikeAdapter,
})

Key Exports

  • createSukooru
  • createSessionStorageAdapter
  • sessionStorageAdapter
  • createMemoryStorageAdapter
  • createDefaultSerializer
  • Types such as SukooruOptions, SukooruInstance, and ScrollStateHandler

Notes

  • Use await sukooru.getKeys() when you need the authoritative key list. sukooru.keys is a synchronous snapshot for convenience.
  • sessionStorageAdapter falls back to in-memory storage when the browser blocks storage access for the current page session.
  • Set window.history.scrollRestoration = 'manual' once on the client if the browser's native restoration conflicts with your app.
  • Use a stable scrollKey such as /products when you want the saved position to belong to a list route instead of the current detail URL.

See Also

  • Root docs: https://github.com/jglee96/sukooru/blob/main/README.en.md
  • Vanilla example: https://github.com/jglee96/sukooru/tree/main/examples/vanilla