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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ya2s
November 22, 2025
83
0
Share
通るURLだけ通す Monorepoで実現する型安全なリンク設計
ya2s
November 22, 2025
More Decks by ya2s
See All by ya2s
デザイン資産をレゴ化!MCPで誰でも作れるLP基盤
ya2s
0
530
Next.js Imageコンポーネントの 舞台裏をのぞく👀
ya2s
0
19
NEWT Tech Talk vol.7 Next.jsとTurborepoで挑む!マイクロフロントエンドのリアル
ya2s
0
120
Featured
See All Featured
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
190
How to make the Groovebox
asonas
2
2.2k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Technical Leadership for Architectural Decision Making
baasie
3
380
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
270
Art, The Web, and Tiny UX
lynnandtonic
304
21k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Paper Plane
katiecoart
PRO
1
50k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
70
39k
Bash Introduction
62gerente
615
210k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
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