CSR / SSR / SSGの動向2020
by
Kazuki Shibata
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
CSR / SSR / SSG ͷಈ2020 ࣲా ف - Wanta, Inc νϟϦςΟʔΧϯϑΝϨϯεԭೄ 2020 Vol.1 Frontendฤ
Slide 2
Slide 2 text
ࣲా ف / Kazuki Shibata Υϯλגࣜձࣾͷڞಉۀऀ $00ɻ NJDSP$.4ͷσβΠϯɺϑϩϯτ ։ൃΛ͍ͯ͠·͢ɻ +BNTUBDL/FYU/VYU͕͖ɻ !TIJCF
Slide 3
Slide 3 text
No content
Slide 4
Slide 4 text
microCMSͷհ • ຊͷϔουϨεCMS • ඇΤϯδχΞͰ͍͍͢ཧը໘ • ίϯςϯπAPIܦ༝Ͱऔಘ • ॊೈͳݖݶཧ • Jamstackͱͷ૬ੑ˕
Slide 5
Slide 5 text
CSR ΫϥΠΞϯταΠυϨϯμϦϯά
Slide 6
Slide 6 text
ΫϥΠΞϯταΠυϨϯμϦϯά • ΫϥΠΞϯταΠυͰϖʔδΛߏங͢Δ • SPAʢγϯάϧϖʔδΞϓϦέʔγϣϯʣ͕ίϨʹ͋ͨΔ • αʔόʔϨεSPA͕ΠέͯΔ • ExpressͳͲαʔόʔαΠυϑϨʔϜϫʔΫ༻͠ͳ͍ • ϒϥβͱσʔλͷΓऔΓΛߦ͏APIͯ͢Cloud FunctionΛ༻͍Δ • microCMSαʔόʔϨεSPAߏ
Slide 7
Slide 7 text
αʔόʔϨεSPAߏʢAWS൛ʣ ϒϥβ CloudFront ʢCDNʣ S3 ʢStorageʣ Lambda ʢCloud Functionʣ HTML / JS / CSS / ը૾ औಘɺૹ৴ɺݕࡧ Ωϟογϡ DynamoDB ʢDatabaseʣ CognitoʢIdentityʣ ೝ ূ σʔλ API Gateway JSON
Slide 8
Slide 8 text
αʔόʔϨεSPAͷϝϦοτ • ϖʔδભҠ࣌JSONͷΓऔΓͷΈͰࡁΉͷͰ͍ • Webαʔόʔͷཧ͕ෆཁ • େྔΞΫηε͞ΕͯΦʔτεέʔϧ͢ΔͷͰ৺ͳ͠ →ϩάΠϯ͕ඞཁͳWebΞϓϦέʔγϣϯ͖
Slide 9
Slide 9 text
αʔόʔϨεSPAͷσϝϦοτ • ϝσΟΞͳͲݕࡧIndex͕ඞਢͳഔମʹ͔ͳ͍ • ҰԠGoogleIndexͯ͘͠ΕΔ͕ɺTwitterSlackͰͷOGPల։ ͞Εͳ͍
Slide 10
Slide 10 text
SSR + CSR αʔόʔαΠυϨϯμϦϯά
Slide 11
Slide 11 text
αʔόʔαΠυϨϯμϦϯά + CSR • ॳظϩʔυ࣌ͷΈαʔόʔαΠυͰHTMLΛߏங͠ɺϖʔδભҠҎ߱ CSRʢΫϥΠΞϯτϨϯμϦϯάʣΛߦ͏ΈΛࢦ͢ • SPAͷSEOܽɺॳظϩʔυΛิͬͨߏ • ͱͱ࣮͕͔ͳΓେม͕ͩͬͨɺNext / Nuxt ͷొͰ͍ͩͿ ෑډ͕Լ͕ͬͨ
Slide 12
Slide 12 text
αʔόʔαΠυϨϯμϦϯάͷϝϦοτ • SEOͳ͠ • ॳظϩʔυΊ
Slide 13
Slide 13 text
αʔόʔαΠυϨϯμϦϯάͷσϝϦοτ • Webαʔόʔ͕ඞਢ ʢྫ͑ϗεςΟϯάαʔόʔ͚ͩͰಈ͔ͤͳ͍ʣ • ࣮қ͕ߴ͍
Slide 14
Slide 14 text
SSG ελςΟοΫαΠτδΣωϨʔτ
Slide 15
Slide 15 text
ελςΟοΫαΠτδΣωϨʔτ • ੩తϖʔδΛࣄલʹੜ͠ɺ৴͢Δ • ୯ͳΔ੩తϖʔδͳͷͰ͍͠ηΩϡΞ • Movable TypeɺHugoɺJekyllɺHexoɺNextɺNuxtɺetc…
Slide 16
Slide 16 text
Jamstack SSG + CSR
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
Jamstack • ࣄલϏϧυͨ͠੩తϑΝΠϧΛ৴ʢʴAPIʹΑΔॲཧʣ • SSG + CSRͷϋΠϒϦου • ॳظϖʔδࣄલϏϧυͨ͠੩తϑΝΠϧΛϩʔυ͠ɺϖʔδભҠ࣌ CSRΛߦ͏ • ϝσΟΞͳͲɺ੩తίϯςϯπͷଟ͍αΠτʹ͍͍ͯΔ
Slide 19
Slide 19 text
Α͋͘ΔJamstackͷߏ
Slide 20
Slide 20 text
JamstackͷϝϦοτ • ඞཁͳͷ੩తϑΝΠϧͷϗεςΟϯάͷΈ • NetlifyɺGitHub PagesɺS3ɺVercelͳͲʢݸਓར༻ϨϕϧͳΒແྉʣ • APIίʔϧϏϧυ࣌ͷΈ • APIϦΫΤετͷ੍ݶ͕͋ͬͯ҆৺ • ສ͕ҰɺAPI͕མͪͯ҆৺ • ηΩϡΞˍϋΠύϑΥʔϚϯεˍ͍҆
Slide 21
Slide 21 text
JamstackͷσϝϦοτ • ϖʔδ͕ଟ͍ͱϏϧυʹຖճ͕͔͔࣌ؒͬͯ͠·͏ • ϓϨϏϡʔͷ࣮͕ͪΐͬͱ໘ • εςʔδϯάڥΛͲ͏ͬͯߏங͢Δ͔ɺݟ͕·ͩগͳ͍
Slide 22
Slide 22 text
Ϗϧυͷ࠷దԽ Build Optimization
Slide 23
Slide 23 text
JamstackϏϧυ͕9ׂ • JamstackͰ࠷େࣄͳͷϏϧυʂͱݴͬͯաݴͰͳ͍ • جຊతʹͯ͢ͷॲཧΛϏϧυ࣌ʹࡁ·͢ • ϖʔδੜʹ͔͔Δ࣌ؒΛͰ͖ΔݶΓݮΒ͢ͷ͕ॏཁ • ϖʔδੜ࣌ͷAPIϦΫΤετΛ࠷খݶʹ͑Δ • ແବͳॲཧΛݮΒ͢
Slide 24
Slide 24 text
Nuxt Generateͷݕূ • MacBookProʢ13-inch, 2017ʣʹͯݕূ • macOS Catalinaʢ10.15.3ʣ • 3.1GHz Core i5 • ϝϞϦ 16GB • هࣄͷຊจʹʮͪΌΜʯͷ಄5,000จࣈΛදࣔ • هࣄʢ10, 100, 1000, 10000, 100000ʣͷ5छྨͰݕূ
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
ܭଌ݁Ռ هࣄ ฏۉʢඵʣ தԝʢඵʣ https://microcms.io/blog/nuxt-measure-build-time/
Slide 27
Slide 27 text
NuxtͷpayloadʹΑΔ ಈతϧʔςΟϯάੜͷߴԽ • Ϗϧυ࣌ͷAPIϦΫΤετΛݮ͢Δ ͨΊʹɺpayloadΛ༗ޮతʹ͏ • ϧʔςΟϯά࡞࣌ʹίʔϧ͢ΔҰཡ APIͷதΛ֤ϖʔδʹpayloadͱͯ͠ ͢ • APIϦΫΤετ100ຊˠ1ຊ
Slide 28
Slide 28 text
Next.js ͷ Incremental Static Regeneration • SSR / SSG / CSR ͷϋΠϒϦου • ॳճΞΫηε࣌SSR • ୭͔͕ҰͰΞΫηε͢ΕɺͦͷλΠϛϯάͰSSG͕͞ΕΔ • ϖʔδભҠ࣌CSR • TwitterͷσϞ https://static-tweet.now.sh/
Slide 29
Slide 29 text
• Next.jsΛ։ൃ͍ͯ͠ΔVercel͕ࣾఏڙ͍ͯ͠ΔϗεςΟϯάαʔϏε • αʔόʔαΠυॲཧಈ࡞͢Δ • ඞཁ࠷ݶͳՕॴΛSSR͠ɺͰ͖ΔݶΓSSGͯ͠ύϑΥʔϚϯεͷ ࠷େԽΛਤΔͱ͍͏ํ͕͋Γͦ͏ • Next.jsʹαʔόʔαΠυ༻ͷػೳ͕݁ߏ͋ΔͷͰɺNetlifyS3Ͱ ेʹ͍͜ͳͤͳ͍
Slide 30
Slide 30 text
Gatsby ͷ Incremental Builds • Gatsby CloudʢGatsbyࣾͷϗεςΟϯάαʔϏεʣ্ͰࠩϏϧυ Λߦ͏͜ͱ͕Ͱ͖Δ • ॳճϏϧυ͚͔͔ͩ࣌ؒΔ͕ɺ2ճҎ߱ߴʢඵʣ
Slide 31
Slide 31 text
Gatsby ͷ Conditional Page Builds • ͪ͜ΒࠩϏϧυ༻ͷઃఆ • Gatsby Cloud্Ͱͳͯ͑ͦ͘͏ʢະ֬ೝʣ • https://www.gatsbyjs.org/docs/conditional-page-builds/
Slide 32
Slide 32 text
Լॻ͖ϓϨϏϡʔ Preview
Slide 33
Slide 33 text
Jamstackʹ͓͚ΔϓϨϏϡʔಛघ • ϔουϨεCMSʹϏϡʔ͕ͳ͍ͨΊɺϓϨϏϡʔڥΛผͰ ༻ҙ͢Δඞཁ͕͋Δ • CMS্ͰهࣄΛԼॻ͖อଘͨ͠ॠؒʹϓϨϏϡʔ͍ͨ͠ → ຖճϏϧυͯͨ͠Β͔͔࣌ؒΔ → ϓϨϏϡʔը໘෦ͷΈSSR·ͨCSRͰߏங͢Δ
Slide 34
Slide 34 text
εςʔδϯάڥߏஙͷྫ • ຊ൪ڥJamstackɺεςʔδϯάڥSPAͱͯ͠༻ҙ͢Δ • NuxtͰ͍͏ͱɺڥมͰ mode Λ universal / spa ͰΓସ͑Δ
Slide 35
Slide 35 text
Next.js ͷ Preview Mode ػೳ • Next.jsʹαʔόʔϨεؔΛىಈͰ͖ΔAPI Routesͱ͍͏ػೳ͕͋Δ • ͜ΕΛར༻͠ɺϓϨϏϡʔ༻ͷΤϯυϙΠϯτʹΞΫηεͨ͠ࡍʹ֘هࣄʹରͯ͠ϦμΠ ϨΫτΛ͔͚Δ • ͦͷࡍʹPreview༻ͷCookie͕༩͞ΕΔ • هࣄଆͰCookieͷ༗ແΛఆͯ͠ɺԼॻ͖༻ίϯςϯπΛදࣔ͢Δ • SPAڥͳͲͷผڥΛ༻ҙͤͣͱηΩϡΞʹϓϨϏϡʔ͕Մೳ • ৄͪ͘͜͠ΒͰղઆ • https://microcms.io/blog/nextjs-preview-mode/
Slide 36
Slide 36 text
גࣜձࣾΫϥυϫʔΫε༷ͷࣄྫ • ίʔϙϨʔτϖʔδͷϦχϡʔΞϧͰmicroCMSΛ࠾༻ • NuxtͰߏஙɺJamstack • χϡʔεهࣄ3000݅͑ • Ϗϧυ࣌ؒʓʓ • ৄ͘͠ɺTAMੁՈ͞ΜͷηογϣϯͰ
Slide 37
Slide 37 text
·ͱΊ Summary
Slide 38
Slide 38 text
্खʹ͍͚Λ͢Δ • ϩάΠϯ͕͋ΔΑ͏ͳWebΞϓϦέʔγϣϯ͚ʹSPA • ϝσΟΞͳͲ੩తίϯςϯπଟΊͷWEBαΠτʹJamstack • Ͳ͏ͯ͠αʔόʔαΠυͰॲཧΛڬΈ͔ͨͬͨΒSSR
Slide 39
Slide 39 text
࠷ޙʹϫʔΫγϣοϓͷએ • 14:00 - 16:00ʹϧʔϜCͰϫʔΫγϣοϓΓ·͢ • ʮmicroCMS + NuxtͰJamstackϒϩάΛ࡞ͬͯΈΑ͏ʯ • ϫʔΫγϣοϓதʹࢀՃऀશһ͕Jamstackϒϩά͕࡞ΕΔΑ͏αϙʔ τ͠·͢ • RemoͰ։࠵
Slide 40
Slide 40 text
Thanks :) !TIJCF