Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
通るURLだけ通す Monorepoで実現する型安全なリンク設計
Search
ya2s
November 22, 2025
81
0
Share
通るURLだけ通す Monorepoで実現する型安全なリンク設計
ya2s
November 22, 2025
More Decks by ya2s
See All by ya2s
デザイン資産をレゴ化!MCPで誰でも作れるLP基盤
ya2s
0
510
Next.js Imageコンポーネントの 舞台裏をのぞく👀
ya2s
0
19
NEWT Tech Talk vol.7 Next.jsとTurborepoで挑む!マイクロフロントエンドのリアル
ya2s
0
110
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.9k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
520
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
240
Technical Leadership for Architectural Decision Making
baasie
3
340
Why Our Code Smells
bkeepers
PRO
340
58k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Designing for humans not robots
tammielis
254
26k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.6k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Code Reviewing Like a Champion
maltzj
528
40k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
Transcript
௨Δ63-͚ͩ௨͢ .POPSFQPͰ࣮ݱ͢Δܕ҆શͳϦϯΫઃܭ
© 2025 Reiwa Travel, Inc. 2 #BDLHSPVOE d-*/&Ϡϑʔגࣜձࣾ ɹɹɹɹ%FW0QTɺ10ɺ1BZ1BZϑϦϚͷϑϩϯτΤϯυ dגࣜձࣾྩτϥϕϧ
ɹɹɹɹϑϩϯτΤϯυɺ&. /FYUKT3FBDU3FBDU/BUJWF&YQP5ZQFTDSJQU /PEFKT(SBQI2-/FPWJN 👶 ̎ࣇͷɹ🎲 ϘʔυήʔϜ 4/4 ྩτϥϕϧϑϩϯτΤϯυΤϯδχΞc&. ZBTTBO !ZBT@Y !ZBT
© 2025 Reiwa Travel, Inc. 3
© 2025 Reiwa Travel, Inc. 4
© 2025 Reiwa Travel, Inc. 5 TSKaigi Hokuriku 2025 参加者限定
特別クーポン
© 2025 Reiwa Travel, Inc. 今日お話しすること 社内におけるインシデントの恒久対応としてライブラリを開発してOSSに 課題はフロントエンド開発において遷移先のURLを型安全に扱いたい 6
© 2025 Reiwa Travel, Inc. 存在しないURLをリンク先にしてしまった <a href="/dasboard">Dashboard</a> // "dashboard"
を typo
© 2025 Reiwa Travel, Inc. Next.js TypedRoutes <Link href="..."> や
router.push("...") など「存在しないパス」を渡した時に コンパイル時に TypeScript エラーで検出する 8
© 2025 Reiwa Travel, Inc. Next.js TypedRoutesの限界 9 • Dynamic
Routeに弱い(非リテラル化でstringに落ちがち) • Pathのみ。queryの型付けがない • Monorepo(MFE)横断では価値が薄い(アプリ内限定)
© 2025 Reiwa Travel, Inc. ya2s / next-typed-url 10 Next.js
の Pages/App Router からルート情報をスキャンし ルートパラメータやクエリ型まで含めた型安全なURLビルダーを自動生成するCLI/ライブラリ 単一のNext.js.プロジェクトでも Monorepo(micro frontend)でも使える
© 2025 Reiwa Travel, Inc. ya2s / next-typed-url 11 プロジェクトルートで型付きURLの生成を実行
生成されたコードを使ってURLを組み立てる
© 2025 Reiwa Travel, Inc. <Link href={ urls.hotel.build({ route: “/tour/[tourId]",
params: { tourId: “12345", }, searchParams: { country: "jpn", } }).href } ya2s / next-typed-url 12
© 2025 Reiwa Travel, Inc. <Link href={ urls.hotel.build({ route: “/tour/[tourId]",
params: { tourId: “12345", }, searchParams: { country: "jpn", } }).href } ya2s / next-typed-url 13 ルート情報から候補を補完
© 2025 Reiwa Travel, Inc. <Link href={ urls.hotel.build({ route: “/tour/[tourId]",
params: { tourId: “12345", }, searchParams: { country: "jpn", } }).href } ya2s / next-typed-url 14 動的なパラメータも補完・型安全
© 2025 Reiwa Travel, Inc. <Link href={ urls.hotel.build({ route: “/tour/[tourId]",
params: { tourId: “12345", }, searchParams: { country: "jpn", } }).href } ya2s / next-typed-url 15 クエリパラメータも補完・型安全
© 2025 Reiwa Travel, Inc. ya2s / next-typed-url 16 Q.
クエリパラメータはどこから取得しているの? A. page.tsxにtype Queryを定義する(コロケーション)
© 2025 Reiwa Travel, Inc. <Link href={ urls.hotel.build({ route: “/tour/[tourId]",
params: { tourId: “12345", }, searchParams: { country: "jpn", } }).href } Monorepoの場合は、アプリごとの名前空間を補完 ya2s / next-typed-url 17
CONFIDENTIAL © 2025 Reiwa Travel, Inc. 18 ·ͱΊ 型安全なURLの生成のためのライブラリ(next-typed-url)を作成 存在しないURLをリンク先に指定することがなくなる
- Dynamic Routeやクエリパラメータにも対応 - MonoreopもアプリごとにURLを生成 OSSへのContributeお待ちしています!
Thank you! CONFIDENTIAL © 2025 Reiwa Travel, Inc. 19