Skip to content

next-typed-href: nuqs サンプルアプリを examples/ に追加#29

Merged
amotarao merged 17 commits intomainfrom
amon/pc-61-nextjs-sample-app
Apr 22, 2026
Merged

next-typed-href: nuqs サンプルアプリを examples/ に追加#29
amotarao merged 17 commits intomainfrom
amon/pc-61-nextjs-sample-app

Conversation

@amotarao
Copy link
Copy Markdown
Member

@amotarao amotarao commented Apr 20, 2026

Summary

fix https://linear.app/plainbrew/issue/PC-61/nextjs-%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E3%82%A2%E3%83%97%E3%83%AA%E3%81%AE%E4%BD%9C%E6%88%90

  • Add examples/example-next-typed-href-nuqs/ — minimal Next.js App Router app demonstrating defineTypedHrefWithNuqs
  • pnpm-workspace.yaml"examples/*" を追加
  • ParserBuilder<unknown>ParserBuilder<any> に変更(DTS ビルドエラー・型推論エラーの修正)

Structure

examples/example-next-typed-href-nuqs/
├── package.json          # next, nuqs, @plainbrew/next-typed-href (workspace)
├── next.config.ts
├── tsconfig.json
├── app/
│   ├── layout.tsx        # NuqsAdapter でラップ
│   ├── page.tsx          # $href で生成したリンクを並べるトップページ
│   └── search/
│       └── page.tsx      # useQueryStates で q/page を読み、$href でリンク生成
└── lib/
    └── href.ts           # defineTypedHrefWithNuqs のセットアップ

Start

pnpm --filter example-next-typed-href-nuqs dev

Summary by CodeRabbit

  • 新機能
    • Next.jsのサンプルアプリを追加:ホーム/検索画面、型付きクエリパラメータの扱い、ページ遷移(Prev/Next)を示す型安全なURL生成を含む。
  • ドキュメント
    • ルートREADMEとパッケージREADMEにサンプルの案内と起動手順を追記。
  • その他(運用・設定)
    • 開発スクリプト、ワークスペース設定、TypeScript設定、turboタスク、CIビルドステップ、.gitignoreを追加・更新。

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

examples ディレクトリに Next.js App Router + nuqs を使った型安全な例アプリを追加し、ワークスペース設定・Turbo 設定・CI ステップ・README 参照および関連ファイル(レイアウト、ページ、typed href ヘルパー、searchParams)を導入しました。

Changes

Cohort / File(s) Summary
例アプリ設定
examples/example-next-typed-href-nuqs/next.config.ts, examples/example-next-typed-href-nuqs/tsconfig.json, examples/example-next-typed-href-nuqs/.gitignore
Next.js と TypeScript の設定ファイルを追加。Next ビルド成果物・生成型ファイルを .gitignore に追加。
例アプリマニフェスト
examples/example-next-typed-href-nuqs/package.json
例用 package.json を追加(依存関係、dev/build/start/typegen/type-check スクリプト)。
App Router レイアウト & ページ
examples/example-next-typed-href-nuqs/src/app/layout.tsx, examples/example-next-typed-href-nuqs/src/app/page.tsx, examples/example-next-typed-href-nuqs/src/app/search/page.tsx
NuqsAdapter を組み込んだ RootLayout、ホームページ(typed links 使用)、検索ページ(クエリ状態管理と typed links)を追加。
型付きクエリと href ヘルパー
examples/example-next-typed-href-nuqs/src/app/search/searchParams.ts, examples/example-next-typed-href-nuqs/src/lib/href.ts
nuqs のパーサを使った searchParams 定義と defineTypedHrefWithNuqs による $href のワイヤリングを追加。
モノレポ統合 & ツール設定
package.json, pnpm-workspace.yaml, turbo.json
examples/* をワークスペースに含める変更、例用 dev スクリプトを追加、Turbo タスク設定を追加。
CI とドキュメント
.github/workflows/ci.yml, README.md, packages/next-typed-href/README.md
CI にパッケージ群の build ステップを追加し、README に新例の参照を追記。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 分

Possibly related PRs

Suggested reviewers

  • akameco
  • iromonek39

🐇 型を抱えて跳ねるよ、href の小道で、
nuqs と手を繋ぎページがうたうよ。
ワークスペースは広がり、Turbo が走る、
小さな例に大きな扉、さあレビューへ! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、examples/ ディレクトリに nuqs を使用したサンプルアプリを追加することという主要な変更を明確に説明しており、実装内容と完全に一致しています。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch amon/pc-61-nextjs-sample-app

Comment @coderabbitai help to get the list of available commands and usage tips.

@amotarao amotarao changed the title Add Next.js App Router example app for defineTypedHrefWithNuqs next-typed-href: nuqs サンプルアプリを examples/ に追加 Apr 20, 2026
@amotarao amotarao marked this pull request as draft April 20, 2026 11:49
@amotarao amotarao changed the base branch from amon/pc-60-definetypedhrefwithnuqs to amon/pc-62-definetypedhrefwithnuqs-withdefault April 21, 2026 00:34
amotarao and others added 9 commits April 21, 2026 11:52
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…artifacts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@amotarao amotarao force-pushed the amon/pc-61-nextjs-sample-app branch from b9c7ff5 to 20a84d6 Compare April 21, 2026 02:52
@amotarao amotarao marked this pull request as ready for review April 21, 2026 02:54
@amotarao amotarao requested review from akameco and iromonek39 April 21, 2026 02:54
Base automatically changed from amon/pc-62-definetypedhrefwithnuqs-withdefault to main April 21, 2026 03:26
@akameco akameco removed the request for review from iromonek39 April 21, 2026 03:29
Copy link
Copy Markdown

@akameco akameco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workspace:* で参照しているから、example を動かす前に pnpm --filter @plainbrew/next-typed-href build が必要。

npm scriptsのdevにbuildステップ入れるとか
"dev": "pnpm --filter @plainbrew/next-typed-href build && next dev"

</Link>
</li>
<li>
<Link href={$href({ route: "/search", searchParams: { q: "typed", page: null } })}>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullを許容しないので、型エラー。exampleもCIで型チェックした方がいいかも

amotarao and others added 3 commits April 22, 2026 18:30
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…r example

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
turbo.json (1)

4-7: build.outputs に Next.js の成果物も含めるとキャッシュ精度が上がります。

現在は dist/** のみなので、next build を実行するパッケージでは成果物復元が不完全になりやすいです。".next/**"(必要なら !.next/cache/** 除外)追加を推奨します。

差分案
   "tasks": {
     "build": {
       "dependsOn": ["^build"],
-      "outputs": ["dist/**"]
+      "outputs": ["dist/**", ".next/**", "!.next/cache/**"]
     },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@turbo.json` around lines 4 - 7, build の outputs が "dist/**" のみで Next.js
の成果物を含んでおらずキャッシュ復元が不完全になるため、turbo.json の "build" セクション(キー名: "build", プロパティ:
"outputs")に Next.js の出力パターン ".next/**" を追加し、必要ならキャッシュを無視するために "!.next/cache/**"
も追加して成果物を正しくキャッシュ・復元できるように修正してください。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@examples/example-next-typed-href-nuqs/src/app/search/page.tsx`:
- Around line 17-23: input 要素(値を参照している q と onChange で setParams を呼ぶ箇所)が
placeholder のみでラベルがないため支援技術に不親切です。input に一意の id を追加し、その id と紐づく label
を追加してラベルテキスト(例: "Search query" または "検索クエリ")を設定してください。既存の value={q ?? ""} と
onChange={(e) => setParams({ q: e.target.value || null, page: 1 })}
のロジックはそのまま残して input の id と label の for/htmlFor を関連付けるように修正してください。

---

Nitpick comments:
In `@turbo.json`:
- Around line 4-7: build の outputs が "dist/**" のみで Next.js
の成果物を含んでおらずキャッシュ復元が不完全になるため、turbo.json の "build" セクション(キー名: "build", プロパティ:
"outputs")に Next.js の出力パターン ".next/**" を追加し、必要ならキャッシュを無視するために "!.next/cache/**"
も追加して成果物を正しくキャッシュ・復元できるように修正してください。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7dcc3a8d-3242-45ca-b5a6-38eb8d817778

📥 Commits

Reviewing files that changed from the base of the PR and between 05597d3 and 098d9c1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • examples/example-next-typed-href-nuqs/.gitignore
  • examples/example-next-typed-href-nuqs/next.config.ts
  • examples/example-next-typed-href-nuqs/package.json
  • examples/example-next-typed-href-nuqs/src/app/layout.tsx
  • examples/example-next-typed-href-nuqs/src/app/page.tsx
  • examples/example-next-typed-href-nuqs/src/app/search/page.tsx
  • examples/example-next-typed-href-nuqs/src/app/search/searchParams.ts
  • examples/example-next-typed-href-nuqs/src/lib/href.ts
  • examples/example-next-typed-href-nuqs/tsconfig.json
  • package.json
  • pnpm-workspace.yaml
  • turbo.json

Comment on lines +17 to +23
<div>
<input
type="text"
placeholder="Search query"
value={q ?? ""}
onChange={(e) => setParams({ q: e.target.value || null, page: 1 })}
/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

入力欄に明示ラベルを付けてください。

Line 18 の input は placeholder のみで、支援技術利用時の識別が弱くなります。labelid の関連付けを追加してください。

修正案
       <div>
+        <label htmlFor="search-query">Search query</label>
         <input
+          id="search-query"
           type="text"
           placeholder="Search query"
           value={q ?? ""}
           onChange={(e) => setParams({ q: e.target.value || null, page: 1 })}
         />
       </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div>
<input
type="text"
placeholder="Search query"
value={q ?? ""}
onChange={(e) => setParams({ q: e.target.value || null, page: 1 })}
/>
<div>
<label htmlFor="search-query">Search query</label>
<input
id="search-query"
type="text"
placeholder="Search query"
value={q ?? ""}
onChange={(e) => setParams({ q: e.target.value || null, page: 1 })}
/>
</div>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@examples/example-next-typed-href-nuqs/src/app/search/page.tsx` around lines
17 - 23, input 要素(値を参照している q と onChange で setParams を呼ぶ箇所)が placeholder
のみでラベルがないため支援技術に不親切です。input に一意の id を追加し、その id と紐づく label を追加してラベルテキスト(例:
"Search query" または "検索クエリ")を設定してください。既存の value={q ?? ""} と onChange={(e) =>
setParams({ q: e.target.value || null, page: 1 })} のロジックはそのまま残して input の id と
label の for/htmlFor を関連付けるように修正してください。

amotarao and others added 5 commits April 22, 2026 18:42
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@amotarao
Copy link
Copy Markdown
Member Author

@akameco 以下対応したので再レビューお願いします 🙏

  • turborepo 対応
  • README.md 追加
  • CI 追加

@amotarao amotarao requested a review from akameco April 22, 2026 09:59
Copy link
Copy Markdown

@akameco akameco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM〜

@amotarao amotarao merged commit eac00a3 into main Apr 22, 2026
2 checks passed
@amotarao amotarao deleted the amon/pc-61-nextjs-sample-app branch April 22, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants