Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Yahoo!クイックマート管理画面でNext.js + static exportsを選んだ理由

Yahoo!クイックマート管理画面でNext.js + static exportsを選んだ理由

Findy社主催
【Next.js特集】フロントエンド技術選定の裏側 〜直面する技術的課題とは?〜
での登壇資料です。

株式会社出前館

March 18, 2025
Tweet

More Decks by 株式会社出前館

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ Յखן (ΧσΧϧ) ࢤ࿕ ॴଐ - LINE Ϡϑʔגࣜձࣾ - גࣜձࣾग़લؗʹग़޲த

    ܦྺ - ~ 2021೥ WEB੍࡞ͷ࢓ࣄ - 2021೥ LINE GrowthTechnology ೖࣾ (ϑϩ ϯτΤϯυΤϯδχΞ) - 2022೥͔Βग़લؗʹग़޲ ԭೄ͔ΒϑϧϦϞʔτͰࢀՃ
  2. ίϯϏχ΍εʔύʔͳͲͰൢച͞Ε͍ͯΔੜ઱৯඼΍ ೔༻඼Λ஫จ で ͖Δ デ Ϧ バ Ϧʔαʔ ビ ε

    Yahoo!γϣοϐϯά಺ʹ͋Γ·͢ɻ ࡢ೥ͷ8݄ʹϦϦʔεͯ͠ର৅ΤϦΞΛͪΌͪ͘Ό͘ͱ޿͍͍͛ͯͬͯΔ Yahoo!ΫΠοΫϚʔτ
  3. ݕ౼ͨ͠ߏ੒ - Next.js (pages router) + static exports - vite

    + react-router-dom બఆ࣌ظ͸ 2023/11
  4. Next.js + static exports vite + react-router-dom static exports Ͱ

    Dynamic routes Λར༻͢Δʹ͸ nginx ͳͲͰ rewrite ͕ඞཁ - /post/[id].tsx -> /post/[id].html ͕ੜ੒͞ΕΔ - /post/xxx -> /post/[id].html ʹ rewrite Next.jsͷݒ೦
  5. Next.jsͷݒ೦ static exports Ͱ Dynamic routes Λར༻͢Δʹ͸ nginx ͳͲͰ rewrite

    ͕ඞཁ - /post/[id].tsx -> /post/[id].html ͕ੜ੒͞ΕΔ - /post/xxx -> /post/[id].html ʹ rewrite Next.js + static exports vite + react-router-dom nginx Λ࣋ͭͷ͸ආ͚͍ͨ vite + react-router-dom Λࢼͦ͏
  6. vite + react-router-dom Λࢼ͢ const router = createBrowserRouter({ path: "/about",

    element: <About /> }) ίʔυʹϖʔδύεͱରԠ͢ΔίϯϙʔωϯτΛఆٛ͢Δ ※બఆ౰࣌ v16 ͷॻ͖ํ Next.js + static exports vite + react-router-dom ϧʔςΟϯάͲ͏΍ͬͯઃఆ͢Δͷʁ
  7. vite + react-router-dom Λࢼ͢ const router = createBrowserRouter({ path: "about",

    lazy: () => import("./routes/About"), }) Next.js + static exports vite + react-router-dom Code Splitting ͸Ͳ͏΍Δͷʁ lazy ʹίϯϙʔωϯτΛ dynamic import ͢Δؔ਺Λ౉͢
  8. ΍ͬͺΓ Next.js ͕͍͍… - react-router-dom ׳ΕΔ·Ͱ͔͔࣌ؒΓͦ͏ - ϝϯόʔશһ Next.js Ͱͷ

    file-system based router ʹ׳Ε͍ͯΔ - Next.js ͳΒ Code splitting ͳͲϏϧυ࠷దԽΛࣗಈͰͯ͘͠ΕΔ Next.js + static exports vite + react-router-dom
  9. Ͱ΋Next.jsʹ͸ݒ೦͕… - Dynamic routes Λར༻͢ΔͨΊʹ͸ nginx ͳͲͰ rewrite ͢Δඞཁ͕͋Δ -

    /post/xxx -> /post/[id].html ʹ rewrite Next.js + static exports vite + react-router-dom
  10. - Dynamic routes Λར༻͢ΔͨΊʹ͸ nginx ͳͲͰ rewrite ͢Δඞཁ͕͋Δ - Dynamic

    routes ࢖Θͳ͍ - ύϥϝʔλʔ͸ΫΤϦύϥϝʔλʔͰ౉ͤ͹͍͍ Ͱ΋Next.jsʹ͸ݒ೦͕… Next.js + static exports vite + react-router-dom
  11. - Dynamic routes Λར༻͢ΔͨΊʹ͸ nginx ͳͲͰ rewrite ͢Δඞཁ͕͋Δ - Dynamic

    routes ࢖Θͳ͍ - ύϥϝʔλʔ͸ΫΤϦύϥϝʔλʔͰ౉ͤ͹͍͍ - σϑΥϧτͩͱύε໊ͷhtml͕ੜ੒͞ΕΔͷͰ΍ͬͺΓ rewirte ͕ඞཁʁ - /about.tsx ΛϏϧυ͢Δͱ about.html ͕ੜ੒͞ΕΔ - /about ʹΞΫηε͢Δͱ 404 ʹͳΔ Ͱ΋Next.jsʹ͸ݒ೦͕… Next.js + static exports vite + react-router-dom
  12. - Dynamic routes Λར༻͢ΔͨΊʹ͸ nginx ͳͲͰ rewrite ͢Δඞཁ͕͋Δ - Dynamic

    routes ࢖Θͳ͍ - ύϥϝʔλʔ͸ΫΤϦύϥϝʔλʔͰ౉ͤ͹͍͍ - σϑΥϧτͩͱύε໊ͷhtml͕ੜ੒͞ΕΔͷͰ΍ͬͺΓ rewirte ͕ඞཁʁ - /about.tsx ΛϏϧυ͢Δͱ about.html ͕ੜ੒͞ΕΔ - /about ʹΞΫηε͢Δͱ 404 ʹͳΔ - trailingSlashɿ true Λઃఆͪ͠Ό͓͏ - index.html ͕ੜ੒͞ΕΔ /about.tsx → /about/index.html - ౰࣌ར༻Λ૝ఆ͍ͯͨࣾ͠಺ͷϗεςΟϯάઌͰ΋ index.html ʹϑΥʔ ϧόοΫ͞ΕΔ࢓༷ͩͬͨͷͰಛʹϧʔςΟϯάͳͲ͸ෆཁʹ Ͱ΋Next.jsʹ͸ݒ೦͕… Next.js + static exports vite + react-router-dom