- 69
- 468 061
Alexander Lichter
Netherlands
Приєднався 26 лис 2013
Web Engineering Consultant, Managing Director and Nuxt.js team member
Multiple Vue Components in one File? Vue Vine makes it possible
Once again, I'm not kidding 👀
---
Links and Resources:
🔗 Fixed issue with Nuxt github.com/vue-vine/vue-vine/issues/163
🔗 Vue Vine Docs vue-vine.dev/
🔗 Vue Vine Repo github.com/vue-vine/vue-vine
📺 @DejaVueFm #E035 - Error Handling in Vue
---
Chaptermarks:
00:00 Intro
00:16 What's the problem?
02:04 The solution?
02:40 Demo App
04:30 Vue Vine VS Code Extension
05:26 How it works under the hood?
06:27 Building a simple component
07:17 How to handle Props, Events and Slots
09:40 Multiple components in one file
10:53 Why not JSX?
11:45 Another way to write components?
13:00 My opinion
13:27 Wrapping up - what do you think?
---
Links and Resources:
🔗 Fixed issue with Nuxt github.com/vue-vine/vue-vine/issues/163
🔗 Vue Vine Docs vue-vine.dev/
🔗 Vue Vine Repo github.com/vue-vine/vue-vine
📺 @DejaVueFm #E035 - Error Handling in Vue
---
Chaptermarks:
00:00 Intro
00:16 What's the problem?
02:04 The solution?
02:40 Demo App
04:30 Vue Vine VS Code Extension
05:26 How it works under the hood?
06:27 Building a simple component
07:17 How to handle Props, Events and Slots
09:40 Multiple components in one file
10:53 Why not JSX?
11:45 Another way to write components?
13:00 My opinion
13:27 Wrapping up - what do you think?
Переглядів: 3 184
Відео
Vue's Reactivity System got FASTER AGAIN!?
Переглядів 7 тис.День тому
I'm not kidding! It'll happen again, and hopefully other framework reactivity systems will apply similar perf improvements. Links and Resources: 🔗 How it started x.com/johnsoncodehk/status/1840558232093483192 🔗 Johnson improving the reactivity system before github.com/vuejs/core/pull/5912 🔗 alien-signals repo github.com/stackblitz/alien-signals 🔗 Porting findings to Vue.js github.com/vuejs/core...
Headings and Typography in Vue.js (in any framework actually...)
Переглядів 4,3 тис.14 днів тому
How dare you coupling style and semantics Links and Resources: 🔗 Vue Playground play.vuejs.org/#eNqFVN9v0zAQ/ldOeckmtQ0w2ENIi8o0iSE0pnUaDwQhL7km2Rzbsp2tZfR/5 ykTTuqTn1ofPd9d9/9sJ DqVKjxwaDOEhMpitlwaBt1CQVVa2ktnCzVLLQTJVLmGtZQziKepOjhh9TkYokaulEpIPFWnFmkU4ASY ffEHOJfyQmufJVhzCJdEWaf8vMXbJnbu0NYdnFzuTXOoYnsrKIukAuGPZQ6FlI/Jh57vjZCLfqpPZxQgGgTWZFPOqGN0bKagDPmIaZLJWFUf9XdlKCpMGcZvL RjJf/rqbVY3OFjbs...
`shared` - ANOTHER NEW folder in Nuxt 4?!
Переглядів 6 тис.21 день тому
Let's talk about the new folder that is coming up - the `shared` folder 🔥 #nuxt #vue #webdevelopment Links and Resources: 🔗 shared folder issue github.com/nuxt/nuxt/issues/28675 🔗 PR for the folder github.com/nuxt/nuxt/pull/28682#issuecomment-2355130082 📺 Use Nuxt 4 already ua-cam.com/video/Fp04Kw4nBE8/v-deo.html 📺 Nuxt 4 Directory Structure explained ua-cam.com/video/KnCNOp5Pbfs/v-deo.html 📺 I...
All about VoidZero - The Interview with Evan You
Переглядів 5 тис.Місяць тому
Time to talk about VoidZero - with noone else than the new founder (and also creator of Vue and Vite), Evan You! Find out all about how he came up with the idea and vision of a unified toolchain, why he decided to go with VC Funding and how he picked investors, as well as how Evan plans to monetize the company at one point. When we met up during VueFes 2024 in Tokyo, Japan, we found a small roo...
🤯 I MIGRATED a Next.js application to Nuxt.js in 1 HOUR
Переглядів 8 тис.Місяць тому
A lot of people wondered how easy it is to switch over from React and Next.js to Vue and Nuxt.js - In this video you'll see - actually it isn't that difficult. In roughly an hour we will write idiomatic code and convert @t3dotgg's QuickPic app (fully open source) over to the vue-based meta framework with all features that it has! #nextjs #nuxt #nuxtjs #vuejs #vue #webdevelopment Links and Resou...
5 missing Vue.js features
Переглядів 7 тис.Місяць тому
Vue.js is an amazing framework to use and pretty mature. Evan recently even said it comes closer and closer to being feature complete. Nevertheless, there are quite some PRs open and ideas to explore. I also made up my mind about five features which I'd love to see available in Vue and how they can help - so let's figure out what these are! Links and Resources: 🔗 Conditional Props github.com/vu...
🚨 Dependency warnings in a fresh Nuxt application?
Переглядів 4,3 тис.Місяць тому
When using nuxi init to scaffold a new Nuxt application and choose NPM as package manager, you might've seen deprecation warnings - and so did a user on Reddit. But are they relevant? And what do they say? Let's check that out in the video! #nuxtjs #nuxt #vue #webdevelopment Upcoming Conferences I'll join: 🇩🇪 vuejs.de Conf (08.10.24) - 10% Off for vuejs.de Conf with Code LICHTER conf.vuejs.de/t...
Building an Association Manager with Nuxt.js Part 003 (Stream VOD)
Переглядів 1,3 тис.Місяць тому
And we continue building an association manager live on Twitch @ www.twitch.tv/TheAlexLichter/. The VOD shows how Nuxt, NuxtHub, Drizzle, Zod and Nuxt UI are used to build a real-life and open-source software project. GET NUXT UI PRO at lichter.link/nuxt-ui/ * Links: 🔗 Repo: github.com/manniL/association-manager 🔗 Nuxt UI: lichter.link/nuxt-ui * 🔗 Nuxt Hub (sign up for beta, free tier) hub.nuxt...
Nitro and EJS combined?!
Переглядів 1,5 тис.Місяць тому
Some of you might be well aware of EJS, aka one of the most used templating engines in the NodeJS world, especially when using Express back in the days. But did you know that you can also make EJS work with Nitro? And even with unstorage 👀 Let's do it! #nitro #ejs #javascript #webdevelopment Links and Resources: 🔗 10% off for vuejs.de Conf with Code LICHTER conf.vuejs.de/tickets/?voucher=LICHTE...
Building an Association Manager with Nuxt.js Part 002 (Stream VOD)
Переглядів 1,8 тис.2 місяці тому
And we continue building an association manager live on Twitch @ www.twitch.tv/TheAlexLichter/. The VOD shows how Nuxt, NuxtHub, Drizzle, Zod and Nuxt UI are used to build a real-life and open-source software project. GET NUXT UI PRO at lichter.link/nuxt-ui/ * Links: 🔗 Repo: github.com/manniL/association-manager 🔗 Nuxt UI: lichter.link/nuxt-ui 🔗 Nuxt Hub (sign up for beta, free tier) hub.nuxt.c...
Passing Cookies with event.$fetch and useRequestFetch in Nuxt
Переглядів 2,4 тис.2 місяці тому
Ever wondered why cookies are not passed correctly to subrequests - e.g. during SSR or when using Nitro/H3? Then this video is for you. Together we have a look how to pass all the important information, including event context and headers to further calls, eliminating different behavior on server and client. #nuxtjs #nuxt #vue #webdevelopment Links and Resources: 🔗 10% Off for vuejs.de Conf wit...
Nuxt Build or Nuxt Generate?
Переглядів 3,4 тис.2 місяці тому
When creating a Nuxt application, it seems that there are two commands in your package.json to build your application for production: `nuxt build` and `nuxt generate`. Some of you might wonder why there are two commands, what the difference of both are and when to use which one? And that's exactly what you'll find out in less than 15 minutes - in this video 🔥 #nuxt #vue #webdevelopment Links an...
Is Vue the fastest when it comes to SSR?
Переглядів 6 тис.2 місяці тому
The "SSR showdown" benchmark was heavily discussed in the last ten days. In this video, we have a look at the first and the final iteration of the benchmark, issues, results and most importantly - what the results mean for YOU as a developer. Tune in! Links and Resources: 🔗 The updated benchmark post blog.platformatic.dev/ssr-performance-showdown 🔗 The first iteration web.archive.org/web/202408...
Loading Third Party Assets with Nuxt Scripts
Переглядів 3,5 тис.2 місяці тому
Almost every app built loads third party scripts - no matter if it is about analytics, consent management, chat widgets or a UA-cam embed. But third party assets pose various issues, from privacy concerns (hi GDPR) to performance impacts. Luckily, there is a new module to solve these issues! Let's take a look at nuxt/scripts in this video. #nuxt #performance #webdev Links and Resources: 🔗 10% O...
What is BFF?! (With Nuxt, Nitro and h3)
Переглядів 9 тис.3 місяці тому
What is BFF?! (With Nuxt, Nitro and h3)
Nuxt with OTHER backend frameworks?
Переглядів 4,9 тис.3 місяці тому
Nuxt with OTHER backend frameworks?
Are Front-end frameworks a security vulnerability by default?
Переглядів 3,8 тис.3 місяці тому
Are Front-end frameworks a security vulnerability by default?
Route Rules in Nuxt - SSR, SSG, ISR and more
Переглядів 4,1 тис.4 місяці тому
Route Rules in Nuxt - SSR, SSG, ISR and more
We have to talk about Rendering Modes...
Переглядів 3,9 тис.4 місяці тому
We have to talk about Rendering Modes...
Compatibility Date in Nuxt 4 and Nitro
Переглядів 3,7 тис.4 місяці тому
Compatibility Date in Nuxt 4 and Nitro
Patching Packages - The ULTIMATE Guide
Переглядів 2,6 тис.4 місяці тому
Patching Packages - The ULTIMATE Guide
Dynamic Rendering in 2024 - SSR only for Crawlers?
Переглядів 3,2 тис.5 місяців тому
Dynamic Rendering in 2024 - SSR only for Crawlers?
Composition API vs. Options API - One API to Rule Them All?!
Переглядів 4,8 тис.5 місяців тому
Composition API vs. Options API - One API to Rule Them All?!
Adding a new nuxt.com logo with useCookie and routing
Переглядів 3,1 тис.6 місяців тому
Adding a new nuxt.com logo with useCookie and routing
please do..... way more of these
In one of your examples there is an H2 above an H3, with the first one to be visually *smaller* than the second. Based on the Information Architecture of the site this order is the desired one. I'm wondering how your approach covers this case and *respects* the same IA. I cannot think a way to use <Typography/> comps without changing the design of the page. Thanks for the content.
If you have a <Typography/> component with two variants, large and small, you can do <Typography variant="small" as="h2">Small Top heading</Typography> <Typography variant="large" as="h3">Big heading</Typography>
@@TheAlexLichter I wanted to avoid that way cause we end up to the inconsistency you describe in the video. Same tags(i.e. h1 for pages titles) have different visual result. I guess we have to sacrifice something nevertheless, so let;s be that :). Thanks for your time.
can you make different variants out of the same SFC? lets say a button component with different skin or looks
Not really. I'd pass that as prop, or create Components based on that SFC. So classic composition
@@TheAlexLichter Thanks and are you open to discussion about HTML-First framework ideas? hopefully, soon this will be accepted approach that I'm trying to implement. <div --component="counter" --metric-card="eager|./pages/metric-card.html" --metric-card-variant1="lazy|./pages/metric-card.html" --metric-card-variant2="lazy|./pages/metric-card.html" >
Vue Vine this is utter nonsense, just like JSX. And it should only remain a separate plugin, as it is now. SFC is the best there is.
Vue Vine это полнейшая шляпа, как и JSX. И это должно оставаться только отдельным плагином, как сейчас. SFC это лучшее что есть.
Благодарю вас сэр
Hey Alex thanks a lot the great video. I’m still confused about what is the difference between props.title vs ()=> props.title
Thanks! If you want to watch a value from an reactive object (and props are „reactive“), you need to use that „reactive getter“ pattern so the watcher knows when a value updates
For god's sake, just use React
Nah, thanks 😛
Lovely! And TSX/JSX absolutely sucks!
the best of this video is discovering by comments the use of vueuse: "createReusableTemplate". That's great!! thnx!!!!
You are welcome 👏🏻
It's doable in React but usually you just prepare sub parts of the components until you assemble it for the default export return. If you put two unrelated component in single file, is that you just break the best practice?
I don't like this stuff. just stick to vue templating and not jsx. probably this plugin won't last a year. lol
if you would’ve seen the video, you would know that this is in fact using a typical Vue template and no JSX 🫠
I wish this was merged into core. There are too many sacred cows in Vue holding it back
I think it is worth trying the module as it works really well + sharing that sentiment! Eg on GitHub or also here
This ain’t nothing but some pills to cure symptoms. The whole ‘we put things in folders by type’ is the actual sickness. Once you put together the things that belong together, all the naming problems disappear. E.g., you have a page that consist of multiple components. Put everything in one folder, export in index.ts only the things that are meant for the outside world and you can have the same name twice.
React vibe?
Just because you have 2 components in a file?
This is great!
This will be helpful when implementing the "Compound Pattern," where there's a parent-child relationship and the child must be rendered within the parent context. When both components exist in the same file, it emphasizes how tightly coupled the relationship is. Another option is to not export the child components at all and just export the big boss!
We're becoming more and more like React, idk if that's a good thing or a bad thing
Reminds me of Lit(.dev)
You could just use const Comp = defineComponent( (props) => { const count = ref(0) return () => { return h('div', count.value) } }, // extra options, e.g. declare props and emits { props: { /* ... */ } } ) and use it in template like regular sfc component
Absolutely! But writing render functions for larger components is painful 🙈
I thought this was a joke. this just makes code harder to understand especially if you have a lot of components in one file. I think React is the only framework that allows this. Angular, Svelte, Vue all agree that you should have SFC - SINGLE file components.
Did you see Svelte snippets? 👀 svelte.dev/docs/svelte/snippet
Great Episode! Tbh I see nothing wrong with this at all! Just a new tool / an way of doing this, that has its pros and cons like other way. It's all about deciding when to use it!
This destroys the idea of SFC, hence the name single file component. I would stick to SFC, it's the best experience no matter how big the app becomes.
Well, it is - on purpose - no SFC anymore. Does it make sense to put all components in one file? Surely not! But in the case mentioned (and others), it’ll be a benefit so you co-locate code that belongs together
why can’t we just stick to the sfc? why does some random guy have to invent a library for that purpose? if i want multiple components in one file i would use react. one thing i want to say to that guy: just use sfc bro
@@cant_sleeeeplearn to code kid
You could also use TSX for a similar experience - you can then define components inside a SFC 🫨
As mentioned, TSX/JSX works but will not be as performant! This allows you using the known Vue templating syntax
What if we had component templates? :3 <template> <MyComponent /> </template> <template component="MyComponent"> My stuff </template>
We kinda have with VueUse vueuse.org/core/createReusableTemplate/
<script component="MyComponent"> as well
This is an anti-pattern. The component always starts out small and eventually you end up with 10 different components in one file as your app grows. Please don't do this.
That sounds more like "skill issue", no? 🤔
Agree. For projects at the to-do list level, it may be applicable, but for anything bigger, it’s an extremely harmful thing. Nevertheless, thanks to the author of the video!
There is a good reason why you can't write multiple components in one file. It violates the Single Responsibility principle (SRP) and breaks separation of concerns. It's also harder to test each unit. It leads to less readable, dirty code. Each file should ideally represent a single unit of functionality or concern. Having one component per file ensures that the logic, template, and styling for that component are self-contained and easy to understand. Mixing multiple components in one file blurs the boundaries between them, making it harder to determine what each component is responsible for.
2 different functions so 2 different components you can provide. Still gives SoC. Or are you putting all your JS functions in 1 file each? The key part is: you shouldn’t put components in the same file that you’d use inside of others that are outside the file (so, grouping by concern here). Testing shouldn’t be an issue either
I think the idea of multiple components in the same file is reusing small and specific parts of the same section (not used anywhere else in the application). Say you have a component for a list of cards with all its logic, and now you need a component for the card itself. You can create a separate Card.vue component, but it is easier and more convenient to have this Card component in the same file, because you already have all the logic there and don't need to lose context.
If a child component lies in the concern of a parent components it's legit for it to be in one place. As you would never move this unit unpaired. »The logic, template, and styling for that« unit is »self-contained and easy to understand«.
Exactly @fabianwohlfart7249!
I believe you can still achieve SRP and use it as "coupling" for your components,. The next harder question is how do you structure your code based on coupling and cohesions methodology? At the end of the day, we are always making couplings on our component and it's just how you manage those components/modules, unless you want to try and aim for functional cohesions, which is not always easy in one single file
Amazing this is what i need to implent rigth now, thanks again for the great tip and video keep doing it 😊 Btw random question abour nuxt, os there a way to use a Middleware in oate folder level or has to be in each page
Another way of writing components further increases fragmentation... By the way, regarding optimization when using JSX. In the slides from the "Vue Vapor: Reinvention" talk by Kevin Deng (sxzz) at Vue Fes Japan 2024, there's a mention of using JSX, where Vapor also works with JSX (the unplugin-vue-jsx-vapor package by zhiyuanzmj)
Very nice. Just helped TODAY in a current project. How fun is that.
and btw. congrats to 11k
Thanks 🙏🏻
In our case we handle the number of returned data to FE via transformer and based on payload e.g. if FE wanted certain fields, FE can use the fields payload, or conditional approach e.g. pages: employee, profile-page which it then used as condition for transformer in the BE, that way, the FE has ton of options without realliying heavily from BE team.
Thank you for this video! It cleared up a lot of my doubts. But I still have one question: I'm using Nuxt 3.14 and making a `useFetch` request on the `home` page to fetch data from a local SQLite database. I've also configured `routeRules: { '/home': { prerender: true } }`. The problem is, when I run `build` and deploy it to my cloud server, the prerendered page includes the fake local data. How can I set it up to exclude this unnecessary prerendered data?
I agree with this: ua-cam.com/video/QuLfCUh-iwI/v-deo.html
Declaring multiple components in one file doesn't mean that you're defining it inside your render, what the teacher showed in this video link is a very basic mistake and nothing to do with what we're talking about here. Stop using React mental model to misleading your understanding here.
@@ShenQingchuan Two components in a single Vue file is also a mistake, regardless of whether it is defined within the parent component. This approach hides the component inside the module, which can lead to issues. It mentions this as well. Perhaps you misunderstood the message.
@@juanshotHmmm... maybe. Talk is cheap, could you please show a demo or mini reprodu tion that represents what you think is bad, I'd love to discuss with that❤
Thanks Alex, I'm curious to know whether there is a technical limit to the number of 301 redirects applied and also what the performance hit might be on large numbers of 301 redirects (like 300 or so).
Thanks! Your video helped me a lot.
after I had developed with Lit for some years, I was looking for a feature like this in Vue too. it looks on the way
alien-signal package.. not a bad name tbh hahaha
Very cool concept.. would love to see more examples.
While I understand your reasoning behind using this in a large project, i also feel that it's over engineering what should be handled by educating developers with bad habits. Yes, i think it helps to prevent using incorrect semantics, and having types on everything makes me very happy, but the lack of education in the basics of web development is where the real problem lies. Tailwind is great, but only if the person using it understands the semantics of the elements they are applying classes to. While you are trying to prevent these issues, I don't think senior devs should have to spoon-feed over-engineered solutions to more inexperienced devs instead of educating them within the context of a code review. In response to the argument for using this on a large project, this should be handled with a good design system and conversations between the design and dev teams. We all need to hold each other accountable for the sake of good semantics and accessibility. The above is just my humble opinion and I do love your videos. BTW, a mention of, or a video on, the new EU Accessibility Act would be great. A lot of people don't know about it, and your platform would be very helpful in spreading awareness of this.
There are a lot of cases where you need to create a small component and writing it in the same file would be great
Thank you for explaining useFetch. It really cleared things up for me.
Nice video manniL Do you perhaps know why in prod build the websocket broke with the url in `peer.websocket.url` being undefined The preset is `node-server`
up
This smells like React and like a bad pattern, spaghetti ❌
Wait for the video 👀
Disagree. Imagine you have a component and inside of that, a lot of repeated patterns. It would make sense to make those small parts their own component. Now that small component lives with all the others but it's only ever used inside your main component. In fact, you might not want anyone using that small component anywhere else because its use-case is very specific. It makes sense therefore to have this code as a component inside the main component that consumes it. This is one nice thing about React/JSX....probably one of the few cases I think it's better than Vue. Many times I have needed this pattern.
I spent my entire 2023 moving away from that spaghetti pattern: a Nuxt 2 project using JSX syntax with pages containing more than 2,000 lines of TSX, inline-declared components, and significant reactivity issues because some of them were declared within other components. That was definitely not fun at all. Even in React, declaring multiple components in one file is an anti-pattern. In Vue, the way reactivity works makes it even more prone to issues when using this pattern (when declaring these components inside other components), in my opinion. So yes, from my perspective, it’s definitely not a good idea
@@michaelpumo83 i disagree ua-cam.com/video/QuLfCUh-iwI/v-deo.html
Totally not even a relative / similar concept in Vue Vine comparing to what you said and please don't mess it up with what you've learned in React, they have different mental model and it's just an option for developer to choose, not force you to adopt.😅 @@juanshot
Intro is too loud
wait what. this is cool. kinda like jsx bit
Please more vids like this. Thats the kind of content we dont find anywhere else!
technically vue has almost always been push-pull, and actually every reactivity system since like 2015 has been push-pull. When these authors talk about reactivity, they tend to say "pull based semantics" or "pull model" just to emphasize the "pull" part of "push-pull", which changes a lot of things compared to traditional push-based reactivity like rxjs. so this doesn't "switch" from pull to push-pull, that's just a misunderstanding caused by how authors talk about this stuff.
Good points - Thanks for the added info Dev! 🙏🏻 I'll make sure to point that out in the deep dive
This is mind blowing, Alex!
good video alexx
Thank you 🙏🏻