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

@yanuaraditia/config-react

v0.1.13

Published

React bindings for @runtime-config — useRuntimeConfig hook, provider, SSR utilities

Downloads

1,457

Readme

@yanuaraditia/config-react

React bindings for @yanuaraditia/configuseRuntimeConfig hook + SSR utilities.

SPA usage

// main.tsx
import { RuntimeConfigProvider } from '@yanuaraditia/config-react'

createRoot(document.getElementById('root')!).render(
  <RuntimeConfigProvider>
    <App />
  </RuntimeConfigProvider>
)
// AnyComponent.tsx
import { useRuntimeConfig } from '@yanuaraditia/config-react'

export function AnyComponent() {
  const config = useRuntimeConfig()
  return <a href={config.public.apiBase}>API</a>
}

React Router v7 (SSR)

Register the base config once at server startup, then useRuntimeConfig() works in any component — no loader required for public config.

// app/entry.server.tsx  (register once, at module load time)
import baseConfig from '~/runtime.config'
import { setBaseRuntimeConfig } from '@yanuaraditia/config-react/server'

setBaseRuntimeConfig(baseConfig)
// app/root.tsx — RuntimeConfigScript seeds window.__RUNTIME_CONFIG__ for the client
import { Outlet } from 'react-router'
import { useRuntimeConfig } from '@yanuaraditia/config-react/server'
import { RuntimeConfigProvider, RuntimeConfigScript } from '@yanuaraditia/config-react'

export default function Root() {
  // Reads process.env at render time — no loader needed
  const config = useRuntimeConfig()
  return (
    <html lang="en">
      <head>
        <RuntimeConfigScript config={config} />
      </head>
      <body>
        <RuntimeConfigProvider config={config}>
          <Outlet />
        </RuntimeConfigProvider>
      </body>
    </html>
  )
}
// Any component — reads from window.__RUNTIME_CONFIG__ or the provider
import { useRuntimeConfig } from '@yanuaraditia/config-react'

export function AppHeader() {
  const config = useRuntimeConfig()
  return <span>{config.public.appVersion}</span>
}

Need private config in a loader? Use the server import there:

// app/routes/dashboard.tsx
import { useRuntimeConfig } from '@yanuaraditia/config-react/server'

export async function loader() {
  const { dbUrl } = useRuntimeConfig()  // private — never reaches the browser
  const data = await fetchFromDb(dbUrl)
  return { data }
}

Shopify App (React Router v7)

Works with @shopify/shopify-app-react-router out of the box. RuntimeConfigProvider can sit inside or outside Shopify's AppProvider — both work.

// app/root.tsx — no loader needed for public config
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from 'react-router'
import { AppProvider } from '@shopify/polaris'
import { useRuntimeConfig } from '@yanuaraditia/config-react/server'
import { RuntimeConfigProvider, RuntimeConfigScript } from '@yanuaraditia/config-react'

export default function App() {
  const config = useRuntimeConfig()  // reads process.env at render time
  return (
    <html lang="en">
      <head>
        <Meta />
        <Links />
        <RuntimeConfigScript config={config} />
      </head>
      <body>
        <RuntimeConfigProvider config={config}>
          <AppProvider i18n={{}}>
            <Outlet />
          </AppProvider>
        </RuntimeConfigProvider>
        <ScrollRestoration />
        <Scripts />
      </body>
    </html>
  )
}
// app/routes/app._index.tsx — private config stays on the server
import { authenticate } from '~/shopify.server'
import { useRuntimeConfig } from '@yanuaraditia/config-react/server'
import type { LoaderFunctionArgs } from 'react-router'

export async function loader({ request }: LoaderFunctionArgs) {
  const { admin } = await authenticate.admin(request)
  const { shopifyApiKey } = useRuntimeConfig()  // private — never returned to client
  const data = await callSomeApi(shopifyApiKey)
  return { data }
}
// Any component — just call useRuntimeConfig(), no loader or prop drilling needed
import { useRuntimeConfig } from '@yanuaraditia/config-react'

export function AppHeader() {
  const config = useRuntimeConfig()
  return <h1>{config.public.appName}</h1>
}

API

| Export | Description | |---|---| | useRuntimeConfig() (client) | Hook — returns public config from context or window.__RUNTIME_CONFIG__ | | RuntimeConfigProvider | Context provider — exposes public config to the React tree | | RuntimeConfigScript | Inline <script> that seeds window.__RUNTIME_CONFIG__ (SSR) | | useRuntimeConfig() (server) | Returns full config (public + private) — use in loaders/actions only | | setBaseRuntimeConfig() (server) | Register your base config once at startup | | createGetRuntimeConfig() (server) | Factory for standalone getters |