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
89
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
通るURLだけ通す Monorepoで実現する型安全なリンク設計
ya2s
November 22, 2025
More Decks by ya2s
See All by ya2s
デザイン資産をレゴ化!MCPで誰でも作れるLP基盤
ya2s
0
550
Next.js Imageコンポーネントの 舞台裏をのぞく👀
ya2s
0
23
NEWT Tech Talk vol.7 Next.jsとTurborepoで挑む!マイクロフロントエンドのリアル
ya2s
0
120
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
970
Why Our Code Smells
bkeepers
PRO
340
58k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
30 Presentation Tips
portentint
PRO
1
350
Paper Plane (Part 1)
katiecoart
PRO
1
9.7k
Mind Mapping
helmedeiros
PRO
1
290
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
770
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
How to build a perfect <img>
jonoalderson
1
5.8k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
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