The Nuxt Plugin Object Syntax - Wins for Perf, DX and Logic!

  Рет қаралды 3,379

Alexander Lichter

Alexander Lichter

Күн бұрын

💻 Nuxt plugins might not be new for the most of you - but when creating them you probably use a function á la defineNuxtPlugin(function() {...}), or the arrow function equivalent. Even though there is a new syntax that you can use, which is not only "backwards"-compatible but also offers more features along the way.
Key points:
🎛️ Compare the function and object syntax for Nuxt plugins
👩‍💻 Taking a deep look inside the source code
✨ Learn about new features, for example dependsOn and parallel
---
Links:
📺️ Repository pattern and custom $fetch - • Custom $fetch and Repo...
🔗 Code - github.com/manniL/alexander-l...
🔗 Docs - nuxt.com/docs/guide/directory...
🔗 Julien's "all parallel" module - github.com/huang-julien/nuxt-...
Don't forget to hit that "Subscribe" button, ring the notification bell and give a thumbs up!
🌐 Connect further:
Website: www.lichter.io
Twitter/X: / thealexlichter
Twitch: / thealexlichter
Chapters:
00:00 Intro
1:03 Looking into the demo app
3:02 Let's see if it works!
3:25 Why we see an error
3:55 Possible fixes
4:55 Diving into the object syntax & finding a fix
6:25 Defining a name and use dependsOn and solving the problem
8:00 One more for performance with parallel
9:36 What Nuxt 4 might bring us
10:30 The env property
10:52 One last thing - The enforce option
12:35 Summary
Keywords:
defineNuxtPlugin nuxt plugin object syntax

Пікірлер: 35
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
Are you planning to use the object syntax now? 👀
@Saeid-Za
@Saeid-Za 4 ай бұрын
Thank you so much for providing such amazing content ❤. The developer experience of Nuxt is unparalleled. Every aspect of the framework's API is engineered with great care, and even better, these improvements come with free performance boosts. A huge thank you to Daniel and all other contributors for creating such an incredible framework. Please keep the regular uploads coming 🤘.
@TheAlexLichter
@TheAlexLichter 3 ай бұрын
Thank you so much for the kind words 🙏🏻 Really delighted that you enjoy using Nuxt and that the content is helpful 🔥
@virtuoz-ru
@virtuoz-ru 4 ай бұрын
Хорош 👍 Твои видео уже нужно в документацию Nuxt включать.
@wat_question_mark
@wat_question_mark 4 ай бұрын
not only well versed and smart, but also handsome!
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
Thank you 🙏
@productdevbook
@productdevbook 4 ай бұрын
Thank you
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
You are welcome! 🙌
@ojvribeiro
@ojvribeiro 4 ай бұрын
Nuxt is the GOAT ♥
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
💚
@tiagogoncalves2012
@tiagogoncalves2012 4 ай бұрын
Great video again! :) Can you make a video comparing building a package vs a Nuxt module
@TheAlexLichter
@TheAlexLichter 3 ай бұрын
Thanks! You mean building an NPM package vs. Nuxt module?
@EvestDev
@EvestDev Ай бұрын
2:57 OOP
@Ayvengo21
@Ayvengo21 19 күн бұрын
Some times i just hate those auto load magic because as rule it completely different between frameworks and so you always have to learn all those things from scratch.
@TheAlexLichter
@TheAlexLichter 19 күн бұрын
Luckily you can also fully opt out of them 👌🏻
@mnmb961
@mnmb961 13 күн бұрын
Is it a good practice if i were to intiate db connection via plugin server so that it can be used throughout the apps ? Thanks
@TheAlexLichter
@TheAlexLichter 13 күн бұрын
I’d do this in a nitro plugin ☺️
@mnmb961
@mnmb961 12 күн бұрын
@@TheAlexLichter can we do the object syntax for nitro plugin also as in nuxt plugin ?
@dlef
@dlef 4 ай бұрын
could you speak about lots of visits and how to deploy the thing without the corps ? thks you if you do
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
What do you mean with “without the corps”? 👀
@fikreteliyev2266
@fikreteliyev2266 4 ай бұрын
Please show nuxt api interseptor (look like vue axios interseptor)
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
Sure thing! It is documented here and should work - github.com/unjs/ofetch?tab=readme-ov-file#%EF%B8%8F-interceptors but I will dedicate a video to it 👍
@lassdasi
@lassdasi 2 ай бұрын
Why should I define some functions as a plugin (like the $api) instead of importing it explicitly?
@TheAlexLichter
@TheAlexLichter 2 ай бұрын
You can also import them explicitly but the initializing (eg passing runtime config values) might be more tedious.
@wolfphantom
@wolfphantom 4 ай бұрын
my $api isn't being typed by Nuxt, so while it IS present on the NuxtApp it isn't including in the type definition and appears as "unknown"
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
Even after restarting the dev server? 👀
@wolfphantom
@wolfphantom 4 ай бұрын
Yes. Even after a restart, and I’ve also extended the interface in an index.d.ts file as per the website without success.
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
@wolfphantom do you have a reproduction to take a look at? 😊
@SkillnoMusic
@SkillnoMusic 2 ай бұрын
what if i want to use fetch raw?
@TheAlexLichter
@TheAlexLichter 2 ай бұрын
Not sure I understand the question. $fetch.raw should work fine ☺️
@Gaijin101
@Gaijin101 3 ай бұрын
Would a NitroPlugin be similar?
@TheAlexLichter
@TheAlexLichter 3 ай бұрын
Actually not! Nitro plugins are unrelated to Nuxt and run only on the server. It is quite different 😁
Avoid losing Reactivity in your Vue Application
10:32
Alexander Lichter
Рет қаралды 6 М.
1 or 2?🐄
00:12
Kan Andrey
Рет қаралды 44 МЛН
World’s Deadliest Obstacle Course!
28:25
MrBeast
Рет қаралды 159 МЛН
Alat Seru Penolong untuk Mimpi Indah Bayi!
00:31
Let's GLOW! Indonesian
Рет қаралды 15 МЛН
你们会选择哪一辆呢#short #angel #clown
00:20
Super Beauty team
Рет қаралды 16 МЛН
#1 - Playwright with TypeScript - Setup & Installation | First Script
26:05
Naveen AutomationLabs
Рет қаралды 19 М.
useAsyncData vs. useFetch 🤯
15:20
Alexander Lichter
Рет қаралды 7 М.
Is your function REALLY a Vue composable?
10:53
Alexander Lichter
Рет қаралды 9 М.
Integrating WebSockets in Nuxt and Nitro
18:15
Alexander Lichter
Рет қаралды 6 М.
How to use layers in Nuxt 4
5:41
Coding with Martin
Рет қаралды 250
How to create and use an SVG Sprite
18:29
Self Teach Me
Рет қаралды 18 М.
Creating APIs in Nuxt with Daniel Roe
33:33
Treblle
Рет қаралды 10 М.
How to use Nuxt Layers to encapsulate your code
17:08
Alexander Lichter
Рет қаралды 6 М.
Dynamic Components in Vue
14:30
Alexander Lichter
Рет қаралды 6 М.
Best mobile of all time💥🗿 [Troll Face]
0:24
Special SHNTY 2.0
Рет қаралды 3,2 МЛН
Choose a phone for your mom
0:20
ChooseGift
Рет қаралды 6 МЛН
Игровой Комп с Авито за 4500р
1:00
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 2 МЛН
Самый дорогой кабель Apple
0:37
Romancev768
Рет қаралды 258 М.
Урна с айфонами!
0:30
По ту сторону Гугла
Рет қаралды 8 МЛН