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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@hn-studios/react-router

v1.0.5

Published

React Router implementation for Roblox TypeScript

Readme

@hn-studios/react-router

A React-like Router for Roblox with Transitions

Welcome! This is the official documentation for the @hn-studios/react-router package. This package provides a routing solution for your Roblox experiences built with Roblox's TypeScript framework, RbxTs. It allows you to manage navigation between different UI components based on URL paths and includes support for animated transitions.

Author: Harihar Nautiyal

Important Configuration

  1. Update tsconfig.json Add @hn-studios to your typeRoots:
{
  "compilerOptions": {
    "typeRoots": [
      "node_modules/@rbxts",
      "node_modules/@hn-studios",  // Add this line
      "node_modules/@types"
    ]
  }
}

Update default.project.json Add the @hn-studios scope to your Rojo configuration:

{
  "ReplicatedStorage": {
    "$className": "ReplicatedStorage",
    "rbxts_include": {
      "$path": "include",
      "node_modules": {
        "$className": "Folder",
        "@rbxts": {
          "$path": "node_modules/@rbxts"
        },
        "@hn-studios": {           // Add this block
          "$path": "node_modules/@hn-studios"
        }
      }
    }
  }
}

Installation:

npm install @hn-studios/react-router

Features:

  • Navigation: Define routes and navigate between them using paths.
  • Route Matching: Match URLs to specific components based on path patterns.
  • Parameters: Capture dynamic segments in paths using colon syntax (:paramName).
  • Transitions: Apply smooth animations when switching between routes. You can choose from various built-in transition types or customize your own.
  • Context API: Access routing information like the current path and navigation function from any component in your application using useRouter and useParams hooks.

Getting Started:

  1. Import the necessary components:
import { RouterProvider, Routes, Route, Link, useRouter, useParams } from "@hn-studios/react-router";
  1. Wrap your application with RouterProvider:

This component provides the context for routing and manages the current path. You can also set default transition properties here.

function App() {
  return (
    <RouterProvider transition="slide-left" transitionDuration={0.5}> {/* Default transition for all routes */}
      {/* Your application components here */}
    </RouterProvider>
  );
}
  1. Define routes with Routes: This component acts as a container for your routes. You can also override the default transition properties from the RouterProvider.
<Routes transition="fade" transitionDuration={0.3}> {/* Overrides default transition for routes within */}
  <Route path="/" component={HomePage} />
  <Route path="/about" component={AboutPage} />
  <Route path="/products/:productId" component={ProductPage} />
</Routes>
  1. Define individual routes with Route:
  • path: The URL pattern for this route.
  • component: The React component to render for this route.
  • transition (Optional): Overrides the parent Routes or RouterProvider transition.
  • transitionDuration (Optional): Overrides the parent Routes or RouterProvider transition duration.
  1. Create links with Link:

This component allows users to navigate between routes.

<Link to="/">Home</Link>
<Link to="/about">About</Link>
  1. Access route information:
  • useRouter hook: Returns the current routing context object.
  • useParams hook: Returns a map of captured parameters from the current route.

Transitions:

The @hn-studios/react-router package provides several built-in transition types:

  • fade: Fades the new component in and the old component out.
  • slide-left: Slides the new component in from the left and the old component out to the left.
  • slide-right: Slides the new component in from the right and the old component out to the right.
  • slide-up: Slides the new component in from the bottom and the old component out to the bottom.
  • slide-down: Slides the new component in from the top and the old component out to the top.

You can set the transition type and duration on the RouterProvider, Routes, or individual Route components. The order of precedence is Route > Routes > RouterProvider.

Example with Transitions:

function App() {
  return (
    <RouterProvider transition="fade" transitionDuration={0.5}>
      <nav>
        <Link to="/">Home</Link>
        <Link to="/about">About</Link>
        <Link to="/products/123">Product 123</Link>
      </nav>
      <Routes>
        <Route path="/" component={HomePage} />
        <Route path="/about" component={AboutPage} transition="slide-right" /> {/* Overrides default to slide-right */}
        <Route path="/products/:productId" component={ProductPage} />
      </Routes>
    </RouterProvider>
  );
}
// ... (HomePage, AboutPage, ProductPage components remain the same)

In this example:

  • All routes will initially have a fade transition with a duration of 0.5 seconds.
  • The /about route will override this to use a slide-right transition, while keeping the 0.5-second duration.

Additional Notes:

  • This package utilizes Roblox-specific components like frame, textbutton, and TweenService. Ensure you're familiar with these components for proper usage within Roblox.