Slides for Vue Fes Japan 2023
Nozomu Ikuta 28th Oct. 2023Deep Dive to UnJS and Nuxt 3
View Slide
@NozomuIkuta
• Software Engineer• Vue.js-JP Core Staff• Nuxt Contributor• UnJS Member
Introduction
Understand what UnJS isUnderstand how UnJS is used in NuxtIntroductionGoals
2018/01/08 ~ 2019/09/21Nuxt 1
2018/09/21 ~Nuxt 2
2022/11/16 ~Nuxt 3
IntroductionVue 2WebpackLegacy Browsers SupportGood DXNodeVue 3Vite / WebpackEvergreen browsers onlyElegant DXNode / Deno / Bun / WorkerNuxt 2 Nuxt 3
Topic“What makes Nuxt 3 possible?”
UnifiedJavaScriptTools
What UnJS Is
What UnJS IsGoals• High-quality and single-purposeJavaScript utilities• Consistency and compatibilityacross the ecosystem withprojects that work in harmony• Independent development ofsolutions that benefit the majorityof JavaScript ecosystemhttps://github.com/unjs/governance
Packages50+
What UnJS IsHistory~2017 202320222019 ~Nuxt 1.x2018Nuxt 2.xNuxt 3.xUnJSSigma (Nitro)Tools for Nuxt3rd-party projectshttps://nuxt.com/docs/community/roadmap2016-10-26~~2016-10-26 Pooya’s tools2020-07~
What UnJS IsHistory• Nuxt and UnJS are separateindependent ecosystems, butcollaborate closely• Pooya used to lead Nuxt andhanded over the role to Daniel• Pooya now focuses mainly onUnJS and Nitro projectsNuxt AuthorsNuxt LeadSébastien Chopin Alexandre ChopinDaniel Roe Pooya ParsaUnJS Lead
UnJS Project MaintainersWhat UnJS IsMembersSébastien Chopin Harlan Wilton Daniel Roe Pooya Parsa Anthony Fu Johann SchopplichChristian PrestonEstébanNozomu IkutaAlexander Lichter Jan-Henrik DamaschkeXin Du (Clark) HebLuciehttps://github.com/orgs/unjs/teams
UnJS Usage In Nuxt
• CLI• Configuration• Server Engine• Data Fetching• SEO
• The core of Nuxt CLI• Pluggable and composable API• Lazy and async commands• ⚠ Under heavy developmentcittyElegant CLI Buildercalldynamic importdefineCommand()createMain()https://github.com/orgs/unjs/citty
Remote filesRemote filesc12Smart Configuration Loader• Poweres Nuxt Layers and Nitropresets• Supports various formats• Merges multiple sources• Loads remote layers by gigetRemote files.ts .cjs .mjs.conf.env.jsonpackage.jsonmergeloadConfig()https://github.com/unjs/c12https://github.com/unjs/gigetdownloadTemplate()
.output/server/index.mjshackablilityNitroWeb Server That Runs Anywhere• The server engine of Nuxt 3• Full-stack server-side framework• Provider-agnostic deployments with 15+ built-in presets• Will have a dedicated team inupcoming monthsabstractiondefineCoStoragesAssetsAssetsAssetsdefineCoPluginsdefineCoHandlersAssetsAssetsCachesdefineCoHooksnitro buildhttps://github.com/unjs/nitro
h3Minimal H(TTP) Framework• Server routes of Nuxt 3• Super fast route matching• Provides composable utilitiescreateApp()AppeventHandler()handlerhandlerhandlerreqreshttps://github.com/unjs/h3handlerevent
ofetchA better fetch API• Fetcher of Nuxt• Parsing response• Handling errors and auto-retry• Interceptor supportofetch()Resourcesauto-retryinterceptparsehttps://github.com/unjs/ofetch
unheadThe
Nuxt ArchitectureCLI with runtime“hard to extend”connectky / Axiosvue-metacittyc12 / gigetNitro / h3ofetchunheadNuxt 2 Nuxt 3
Summary
• UnJS is an ecosystem of single-purpose utils working in harmony• Nuxt and UnJS are separateindependent ecosystems butcollaborate closely• Nuxt is build on top of UnJSecosystem• The more UnJS evolves, the moreNuxt does
Favorite phrase“[Contribution is] more than welcome”
Thank you