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

@sfwnisme/visi

v1.0.1

Published

solidjs conditional rendering components for reactjs

Readme

@sfwnisme/visi

MIT License npm version TypeScript Next.js

@sfwnisme/visi is a React package that adapts SolidJS's powerful and efficient conditional rendering components. It offers a declarative API to conditionally render components based on given conditions, closely mimicking SolidJS's approach to reactive rendering in React.

This package aims to provide an efficient, easy-to-use, and flexible solution for handling conditional rendering in React applications, inspired by SolidJS's reactivity model.

✨ Features

  • Standardized Components: Use only three components (Visible, Shift, Case) for all conditional rendering scenarios, simplifying code review and debugging.
  • Declarative Syntax: Provides a clean and readable approach for handling conditions, avoiding complex inline logic.
  • Reusable Components: Unify conditional rendering logic into reusable components for consistency across the application.
  • Callback Support: Leverages the Function-as-Children Pattern to pass when prop value as the callback parameter, enhancing flexibility.
  • Simplified Nested Conditions: Handles excessive nested conditions with clear and maintainable component structures.
  • Improved Readability: Reduces clutter in deeply nested logic, making the code easier to understand.
  • Enhanced Bug Tracking: Streamlines debugging by centralizing conditional logic into predictable patterns.
  • Switch Rendering Support: Provides a robust alternative to switch or multiple if-else blocks using Shift and Case components.
  • Consistent Codebase: Eliminates the need for varied snippets, promoting a uniform coding style.
  • React and SolidJS Inspiration: Built to replicate SolidJS's efficient rendering while being tailored to React's ecosystem.
  • Next.js Ready: Fully compatible with Next.js projects.

📦 Installation

Install the package using npm:

npm install @sfwnisme/visi

Or using yarn:

yarn add @sfwnisme/visi

🚀 Usage

Single Render Comparison

🟥 Traditional React

// Approach 1
isAuthorized ? <Dashboard /> : <Login />

// Approach 2
if(!isAuthorized) {
  return <Login />
}
return <Dashboard />

🟩 Visi

// Single condition
<Visible when={isAuthorized} fallback={<Login />}>
  <Dashboard />
</Visible>

// Nested condition
<Visible when={isAuthorized} fallback={<Login />}>
  <Dashboard />
  <Visible when={isLogin}>
    <LogoutButton />
  </Visible>
</Visible>

// Callback condition
<Visible when={user} fallback={<p>loading...</p>}>
  {((userInfo: {name: string, age: string}) => (
    <p>{userInfo.name} is {userInfo.age} years old</p>
  ))}
</Visible>

Shift Render Comparison

🟥 Traditional React

// Ternary approach
role === 'admin'
  ? <AdminDashboard />
  : role === 'supervisor'
    ? <SupervisorDashboard />
    : <UserDashboard />
  : <Login />;

// If-else approach
if(role === 'admin') {
  return <AdminDashboard />
}
if(role === 'supervisor') {
  return <SupervisorDashboard />
}
if(role === 'user') {
  return <UserDashboard />
}
return <Login />

🟩 Visi

<Shift fallback={<Login />}>
  <Case when={role === 'admin'}>
    <AdminDashboard />
  </Case>
  <Case when={role === 'supervisor'}>
    <SupervisorDashboard />
  </Case>
  <Case when={role === 'user'}>
    <UserDashboard />
  </Case>
</Shift>

Excessive Complexity Render Comparison

🟥 Traditional React

<div>
  {user.role === 'admin' &&
    user.permissions.posts.view &&
    <Post>
      <h3>post conetent....</h3>
      {user.permissions.posts.comments.view &&
        <Comment>
          <div className="comment-box">
            <p>comment content...</p>
            {
              user.permissions.posts.comments.delete &&
              <Button>Delete</Button>
            }
            {
              user.permissions.posts.comments.update &&
              <Button>Update</Button>
            }
          </div>
          {user.permissions.posts.comments.reply.view &&
            <Replies>
              <Reply>
                <p>replay one content...</p>
                {
                  user.permissions.posts.comments.reply.delete &&
                  <Button>Delete</Button>
                }
                {
                  user.permissions.posts.comments.reply.update &&
                  <Button>Update</Button>
                }
              </Reply>
              {
                user.permissions.posts.comments.reply.create &&
                <CreateReply />
              }
            </Replies>
          }
        </Comment>
      }
    </Post>
  }
</div>

🟩 Visi

<Visible when={user.role === 'admin'}>
  <Visible when={user.permissions.posts.view}>
    <Post>
      <h3>post conetent....</h3>
      <Visible when={user.permissions.posts.comments.view}>
        <Comment>
          <div className="comment-box">
            <p>comment content...</p>
            <Visible when={user.permissions.posts.comments.delete}>
              <Button>Delete</Button>
            </Visible>
            <Visible when={user.permissions.posts.comments.update}>
              <Button>Update</Button>
            </Visible>
          </div>
          <Visible when={user.permissions.posts.comments.reply.view}>
            <Replies>
              <Reply>
                <p>replay one content...</p>
                <Visible when={user.permissions.posts.comments.reply.delete}>
                  <Button>Delete</Button>
                </Visible>
                <Visible when={user.permissions.posts.comments.reply.update}>
                  <Button>Update</Button>
                </Visible>
              </Reply>
              <Visible when={user.permissions.posts.comments.reply.create}>
                <CreateReply />
              </Visible>
            </Replies>
          </Visible>
        </Comment>
      </Visible>
    </Post>
  </Visible>
</Visible >

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📧 Contact

If you have any questions or suggestions, please open an issue on GitHub.