Teacher @ Vue School
Full Stack developer (10 years)
Husband and Father
Tips for Building Maintanable Apps
https://vuejs.org/style-guide/
app-popup.vue
When you use conventions new and existing team members have to think less
VS Code Extension
Let's take a look at a few examples
Typing Props & Events
Nuxt 3 Supports TypeScript by Default
Nuxt even generates some types on the fly
The response of API endpoints are automatically typed for the front-end
or add in tRPC for end-to-end typesafety
Nuxt 3 provides great community wide conventions
Nuxt 3 provides great community wide conventions
Resources
What it might look like in Nuxt
What it might look like in Nuxt
Could remove partials as routes in production
Can copy
this convention
or come up
with your own
Inspired by Laravel
Front-end Pages (views)
API Endpoints
What it might look like in Nuxt
(Sometimes)
// Http.js
import axios from 'axios'
export default class Http{
async get(url){
const response = await axios.get(url);
return response.data;
}
// ...
}
// Http.js
export default class Http{
async get(url){
const response = await fetch(url);
return await response.json();
}
// ...
}
export default class Http{
async get(url){
try {
const response = await fetch(url);
return await response.json();
} catch (err) {
alert(err);
}
}
// ...
}
// Http.js
import Cache from './Cache.js'
export default class Http{
async get(url){
const cached = Cache.get(url)
if(cached) return cached
const response = await fetch(url);
return await response.json();
}
// ...
}
// AppIcon.vue
<template>
<FontAwesomeIcon v-if="type==='fa'" :icon="icon" />
<md_icon v-if="type=== 'md'">{{icon}}</md_icon>
</template>
<script>
export default{
props:{
type: { type: String, default: 'fa' },
icon: { type: String, required: true }
}
}
</script>
axios('https://someapi.com/posts/1')
post.find(1)
post.find(1)
https://firebase.google.com/
https://vueschool.io/courses/the-vuejs-3-master-class
https://supabase.com/
https://supabase.com/
npx supabase gen types typescript --project-id "$PROJECT_ID" --schema public > types/supabase.ts
Not just because it's the newest and shiniest
Why?
Why?
Because it's easier to spot opportunities for abstraction and code re-use
Use Standards for Predictability
Take advantage of your IDE
Use Nuxt for Standardized File Structure
Adopt a Route Naming Convention
Wrap (Some) 3rd Party Code
Interact with Backends via SDKs
Prefer the Composition API
🔥 Course just completed!
from
April 3
February 2
March 15
🔥 Free
https://certification.vuejs.org/
Grab a FREE limited edition Vue School t-shirt