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

@custom-react-hooks/use-island

v1.0.4

Published

A React hook for island architecture and selective hydration

Readme

useIsland

A React hook for implementing island architecture with selective hydration, allowing you to optimize performance by hydrating components only when needed.

Features

  • 🏝️ Island Architecture: Implement selective hydration patterns
  • Performance Optimized: Hydrate components only when necessary
  • 🎯 Priority Support: Control hydration priority (high, normal, low)
  • 👁️ Visibility Detection: Automatic hydration based on visibility
  • 🔄 Lazy Loading: Support for lazy hydration
  • 📊 State Management: Track hydration and visibility states
  • 🎣 Callbacks: Custom handlers for hydration events
  • 🧹 Auto Cleanup: Automatic cleanup on unmount

Installation

npm install @custom-react-hooks/use-island

Usage

Basic Usage

import React from 'react';
import { useIsland } from '@custom-react-hooks/use-island';

function MyIslandComponent() {
  const { isHydrated, isVisible, hydrate, dehydrate } = useIsland('my-island');

  return (
    <div>
      <p>Hydrated: {isHydrated ? 'Yes' : 'No'}</p>
      <p>Visible: {isVisible ? 'Yes' : 'No'}</p>
      <button onClick={hydrate}>Hydrate</button>
      <button onClick={dehydrate}>Dehydrate</button>
    </div>
  );
}

With Priority

import React from 'react';
import { useIsland } from '@custom-react-hooks/use-island';

function HighPriorityIsland() {
  const { isHydrated, hydrate } = useIsland('critical-island', {
    priority: 'high',
    lazy: false
  });

  return (
    <div>
      {isHydrated ? (
        <ExpensiveComponent />
      ) : (
        <div>Loading...</div>
      )}
    </div>
  );
}

With Callbacks

import React from 'react';
import { useIsland } from '@custom-react-hooks/use-island';

function CallbackIsland() {
  const { isHydrated, hydrate } = useIsland('callback-island', {
    onHydrate: (islandId) => {
      console.log(`Island ${islandId} hydrated`);
      // Analytics, logging, etc.
    },
    onDehydrate: (islandId) => {
      console.log(`Island ${islandId} dehydrated`);
    }
  });

  return (
    <div>
      <button onClick={hydrate}>
        {isHydrated ? 'Hydrated' : 'Hydrate Island'}
      </button>
    </div>
  );
}

Lazy Hydration

import React from 'react';
import { useIsland } from '@custom-react-hooks/use-island';

function LazyIsland() {
  const { isHydrated, isVisible } = useIsland('lazy-island', {
    lazy: true,
    priority: 'low'
  });

  return (
    <div>
      {isHydrated ? (
        <HeavyComponent />
      ) : (
        <PlaceholderComponent />
      )}
    </div>
  );
}

API Reference

Parameters

  • islandId (string): Unique identifier for the island
  • options (IslandOptions, optional): Configuration options

IslandOptions

interface IslandOptions {
  priority?: 'high' | 'normal' | 'low';
  lazy?: boolean;
  onHydrate?: (islandId: string) => void;
  onDehydrate?: (islandId: string) => void;
}

Return Value

interface IslandState {
  isHydrated: boolean;
  isVisible: boolean;
  hydrate: () => void;
  dehydrate: () => void;
}

Properties

  • isHydrated (boolean): Whether the island is currently hydrated
  • isVisible (boolean): Whether the island is visible in viewport
  • hydrate (function): Function to hydrate the island
  • dehydrate (function): Function to dehydrate the island

Use Cases

  1. Performance Optimization: Defer hydration of non-critical components
  2. Progressive Enhancement: Gradually enhance static content
  3. Lazy Loading: Hydrate components when they become visible
  4. Resource Management: Control when expensive components are active
  5. Server-Side Rendering: Optimize SSR with selective hydration
  6. Mobile Optimization: Reduce initial bundle size and improve performance

TypeScript Support

This hook is written in TypeScript and provides full type safety:

import { useIsland, IslandOptions, IslandState } from '@custom-react-hooks/use-island';

const options: IslandOptions = {
  priority: 'high',
  lazy: false
};

const island: IslandState = useIsland('my-island', options);

License

MIT © Bane Grozdanovic