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

@croco/frontend-react

v0.0.2

Published

> Croco Presentation Tier — 5th layer: Framework → Protocols → Transports → Integrations → Presentation

Downloads

79

Readme

@croco/frontend-react

Croco Presentation Tier — 5th layer: Framework → Protocols → Transports → Integrations → Presentation

React 앱에서 Croco의 SSR 기능을 사용하기 위한 유틸리티 패키지입니다.

이 패키지는 React 앱에서 Vike와 함께 Croco의 SSR 데이터 전송 기능을 사용하기 위한 훅과 설정 함수를 제공합니다.

설치

pnpm add @croco/frontend-react

사용법

페이지 설정

각 페이지의 +config.ts에서 기본 설정을 사용합니다:

// pages/index/+config.ts
import { createCrocoPageConfig } from "@croco/frontend-react";

export default createCrocoPageConfig({ ssr: true });

데이터 전송

페이지 데이터를 전송하려면 +data.ts에서 함수를 정의합니다:

// pages/index/+data.ts
import { type CrocoDataFn } from "@croco/frontend-react";

export const data: CrocoDataFn<{ message: string }> = async () => {
  return {
    message: "Hello from SSR!",
  };
};

React에서 데이터 사용

usePageData 훅으로 타입 안전하게 데이터에 접근합니다:

// pages/index/+Page.tsx
import { usePageData } from '@croco/frontend-react';

export default function Page() {
  const data = usePageData<{ message: string }>();

  return <div>{data.message}</div>;
}

API

createCrocoPageConfig(options?)

Vike 페이지 설정의 기본값을 제공합니다.

옵션:

  • ssr?: boolean - SSR 활성화 여부 (기본값: true)

반환값:

{
  ssr: boolean;
  passToClient: readonly[("data", "title", "description")];
}

usePageData<T>()

Vike의 usePageContext를 래핑하여 데이터에 타입 안전 접근을 제공합니다.

제네릭:

  • T - 페이지 데이터 타입 (기본값: unknown)

반환값: T

타입

CrocoPageContext

페이지 컨텍스트 타입입니다.

export type CrocoPageContext = {
  urlOriginal: string;
  data?: unknown;
  title?: string;
  description?: string;
  env?: Record<string, unknown>;
};

CrocoDataFn<T>

페이지 데이터 전송 함수 타입입니다.

export type CrocoDataFn<T = unknown> = (pageContext: CrocoPageContext) => Promise<T> | T;

라이선스

MIT