New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@sirou/next

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sirou/next

Next.js adapter for Sirou — App Router, Pages Router, middleware, and server utilities

latest
Source
npmnpm
Version
1.1.3
Version published
Maintainers
1
Created
Source

@sirou/next

The Next.js adapter for Sirou. Supports both the App Router (Next.js 13+) and the Pages Router, providing type-safe navigation, middleware utilities, and server-side route helpers.

Installation

npm install @sirou/next @sirou/core

Setup

App Router (Next.js 13+)

Create a client component to provide the router context:

// app/providers.tsx
"use client";
import { SirouNextProvider } from "@sirou/next";
import { routes } from "@/routes";

export function Providers({ children }: { children: React.ReactNode }) {
  return <SirouNextProvider config={routes}>{children}</SirouNextProvider>;
}
// app/layout.tsx
import { Providers } from "./providers";

export default function RootLayout({ children }) {
  return (
    <html>
      <body>
        <Providers>{children}</Providers>
      </body>
    </html>
  );
}

API Reference

SirouNextProvider

Context provider for App Router. Wraps next/navigation internally.

useSirouNextRouter()

Returns the Sirou router instance backed by next/navigation.

"use client";
import { useSirouNextRouter } from "@sirou/next";

const router = useSirouNextRouter<typeof routes>();
router.go("dashboard");

buildUrl(routeName, params?)

Server-safe URL builder. Can be used in Server Components, generateMetadata, and API routes.

import { buildUrl } from "@sirou/next";

// In generateMetadata
export async function generateMetadata({ params }) {
  return {
    alternates: {
      canonical: buildUrl("products.details", { productId: params.id }),
    },
  };
}

createSirouMiddleware(config)

Creates a Next.js middleware function that runs Sirou guards on the edge.

// middleware.ts
import { createSirouMiddleware } from "@sirou/next";
import { routes } from "./routes";

export const middleware = createSirouMiddleware(routes, {
  guards: {
    auth: async ({ request }) => {
      const token = request.cookies.get("token");
      if (!token) return { allowed: false, redirect: "/login" };
      return { allowed: true };
    },
  },
});

export const config = {
  matcher: ["/dashboard/:path*"],
};

Type-safe link component using next/link under the hood.

import { SirouLink } from "@sirou/next";

<SirouLink to="user" params={{ id: "abc" }} prefetch>
  View Profile
</SirouLink>;

License

MIT

Keywords

routing

FAQs

Package last updated on 03 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts