Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
通るURLだけ通す Monorepoで実現する型安全なリンク設計
Search
ya2s
November 22, 2025
0
68
通るURLだけ通す Monorepoで実現する型安全なリンク設計
ya2s
November 22, 2025
Tweet
Share
More Decks by ya2s
See All by ya2s
デザイン資産をレゴ化!MCPで誰でも作れるLP基盤
ya2s
0
460
Next.js Imageコンポーネントの 舞台裏をのぞく👀
ya2s
0
18
NEWT Tech Talk vol.7 Next.jsとTurborepoで挑む!マイクロフロントエンドのリアル
ya2s
0
110
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1032
470k
Raft: Consensus for Rubyists
vanstee
141
7.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Faster Mobile Websites
deanohume
310
31k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
We Have a Design System, Now What?
morganepeng
54
7.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
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