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

@obosbbl/grunnmuren-react

v3.3.4

Published

Grunnmuren components in React

Readme

@obosbbl/grunnmuren-react

npm canary version

Grunnmuren React components.

Install

# npm
npm install @obosbbl/grunnmuren-react@canary

# pnpm
pnpm add @obosbbl/grunnmuren-react@canary

Setup

Internationalization

Grunnmuren uses React Aria Components under the hood. RAC has built in translation strings for non visible content (for accessibility reasons). It also automatically detects the language based on the browser or system language.

To ensure that the language of the page content matches the accessibility strings you must wrap your application in a GrunnmurenProvider with a locale prop. This will override RAC's automatic locale selection.

In Next.js you can do this in the root root layout. In order to avoid making RootLayout a client component, you should import GrunnmurenProvider in a providers-file, that uses "use client"

Valid locales are nb, sv or en. The provider defaults to nb if unspecified.

// app/providers.tsx
'use client'
import { GrunnmurenProvider } from '@obosbbl/grunnmuren-react';

export function Providers({children, locale}: { children: React.ReactNode, locale: 'nb' | 'sv' | 'en'}) {

  return (
    <GrunnmurenProvider locale={locale}>
      {children}
    </GrunnmurenProvider>
  )
}
// app/layout.tsx

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {

  // Either 'nb', 'sv' or 'en'
  const locale = 'nb';

  return (
    <Providers locale={locale}>
      <html lang={locale}>
        <body>{children}</body>
      </html>
    </Providers>
  )
}

See the RAC internationalization docs for more information.

Routing

When using compontents that include links from RAC (For example Breadcrumbs), the links will always treat the hrefs as external.

In order to avoid hard refreshing, you need to prop your router navigation-function through GrunnmurenProvider. See the RAC routing docs

In Next.js this is also done in the root root layout. In order to avoid making RootLayout a client component, you should import GrunnmurenProvider in a providers-file, that uses "use client"

// app/providers.tsx
'use client'
import { GrunnmurenProvider } from '@obosbbl/grunnmuren-react';
import { useRouter } from 'next/navigation';

export function Providers({children, locale}: { children: React.ReactNode, locale: string}) {
  const router = useRouter();

  return (
    <GrunnmurenProvider locale={locale} navigate={router.push}>
      {children}
    </GrunnmurenProvider>
  )
}

The RootLayout file then looks exactly like it does in the previous step:

// app/layout.tsx
import {Providers} from "./providers";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode
}) {

  // Either 'nb', 'sv' or 'en'
  const locale = 'nb';

  return (
    <Providers locale={locale}>
      <html lang={locale}>
        <body>{children}</body>
      </html>
    </Providers>
  )
}

Basepath

If you're using a router such as Next's, then you can use the useHref prop to convert router-specific hrefs into native HTML hrefs. This is very useful for instance when using Next's basepath setting, as you can use this to prepend the basepath to all links, similar to Next's <Link>.

Before

import Link from 'next/link';
import { Button } from '@obosbbl/grunnmuren-react';

// Notice how you have to handle the basepath yourself with Grunnmuren's component, but not with Next's.

<Link href="/bli-medlem">Bli medlem</Link>
<Button href="/medlem/bli-medlem">Bli medlem</Button>

After

// app/providers.tsx
'use client'
import { GrunnmurenProvider } from '@obosbbl/grunnmuren-react';
import { useRouter } from 'next/navigation';

export function Providers({children, locale}: { children: React.ReactNode, locale: string}) {
  const router = useRouter();
  const useHref = (href: string) => '/medlem' + href;

  return (
    <GrunnmurenProvider locale={locale} navigate={router.push} useHref={useHref}>
      {children}
    </GrunnmurenProvider>
  )
}
import Link from 'next/link';
import { Button } from '@obosbbl/grunnmuren-react';

// The hrefs are the same, as basepath is handled by the useHref hook in the provider.

<Link href="/bli-medlem">Bli medlem</Link>
<Button href="/bli-medlem">Bli medlem</Button>

Optimize bundle size by removing unused locales

React Aria Components has built in support for over 30 languages, most of which will be unused in your application. To optimize your applications bundle size, it is recommended to use React Aria's build plugin to remove all the unused locales. Here is a quick example for Next.js:

Install

# npm
npm install @react-aria/optimize-locales-plugin --save-dev

# pnpm
pnpm add -D @react-aria/optimize-locales-plugin

Configuration

// next.config.js
const optimizeLocales = require('@react-aria/optimize-locales-plugin');

module.exports = {
  webpack(config) {
    config.plugins.push(
      optimizeLocales.webpack({
        // If you have a multitenant app, include both Norwegian and Swedish
        // If your app only serves one language, adjust accordingly
        locales: ['nb', 'sv'],
      }),
    );
    return config;
  },
};

The plugin works with several different bundlers. See React Aria's bundle size optimization docs for more information.

Usage

Before you start using the components you need to configure the Tailwind preset. Remember to add this package to the content scan.

import { Button } from '@obosbbl/grunnmuren-react';

export default function () {
  return <Button>Click me</Button>;
}