#380

fix(next-docs): quick start exports a Page that createNextApp does not return

Opencoygeekopened 1mo ago

Summary

The Next package README destructures Page from createNextApp() and re-exports it as a route's default component. The function returns getPageData, generateMetadata, and generateStaticParams, so the documented Page is undefined.

Steps to reproduce

  1. Follow steps 2 and 3 of packages/next/README.md for 0.21.0.
  2. Inspect the return keys of the helper before re-exporting the route.
import { createNextApp } from "@json-render/next/server";

const spec = {
  routes: {
    "/": {
      page: {
        root: "hero",
        elements: {
          hero: { type: "Card", props: { title: "Welcome" }, children: [] },
        },
      },
    },
  },
};
const app = createNextApp({ spec });
console.log(Object.keys(app));
console.log("Page" in app);

Expected behavior

The README should provide a working route setup using the helper's actual API. A consumer following the example should have a defined page component that resolves route data and renders it.

Actual behavior

The inspected helper returns only getPageData, generateMetadata, and generateStaticParams. A pinned consuming helper probe records these same three return keys. Page is absent, so the README's destructured default route component is undefined.

Affected area

Steps 2 and 3 of packages/next/README.md.

Runtime or environment

Documentation and helper source inspected at fc2a696a50a30cb30c878ab1eb65e102487eea0f, package version 0.21.0. The preserved consuming helper probe ran on Node v22.23.2. This report does not claim a complete Next application build was executed.

Evidence

The README destructures Page and re-exports it as default. The helper source returns getPageData instead, and its inline example already demonstrates a server page calling that method and rendering a separate client component.

Impact

The package's quick start cannot provide the route component it instructs consumers to export. The closure signal is a README route example that matches the helper return type and yields a real page component.

Activity

1
Jassi200426d ago

Addressed in #402. The examples now call getPageData() from an explicit server page and render through a client component that owns the registry and provider. Metadata/static generation and notFound() handling are preserved.

Built a consumer from the README snippets and checked both documented routes, their content/layout/metadata, and an unmatched route's 404 response. All 61 workspace type-check tasks and 122 docs route/parity checks pass.