🔠#20: Personal Set-backs, Returning Composables from Composables, and Docker on VPS
Reflections on conferences, Vue.js composables and Docker deployments with Kamal on Hetzner VPS. Join the conversation on best practices in Vue and insights into efficient cloud deployment strategies.
Hey,
Long time no see! I want to start this newsletter with some personal reflections before diving into my thoughts about returning Composables from Composables and using Docker with a VPS like Hetzner via Kamal.
After speaking at several amazing conferences last year, I received 100% rejections for in-person conferences for 2024. It's a tough pill to swallow, but looking at the lineups of the conferences, I have to admit that the people I see there are just better. And they contribute more to the ecosystem than I do.
I don't know yet what to make of this. Stop applying for conferences? Up my game contributing to the community again? I have to think about it.
I'm thankful for all the thoughtful comments under my LinkedIn post regarding this.
Now, let's dive into more technical matters!
Is Returning Composables from Composables an Anti-Pattern in Vue Applications?
Consider this scenario: we have a useProduct()
composable that returns a useList()
composable.
// composables/product.ts
export const useProduct = () => {
const { invoke, useGet } = useApi();
return {
useList() {
return useGet('/api/products');
},
async remove() {
await invoke('/api/products', {
method: 'DELETE',
});
},
};
};
And its usage in a Vue component:
<script setup lang="ts">
import { useProduct } from '../composables/product.ts';
const { useList, remove } = useProduct();
const { data: products } = await useList();
</script>
<template>
<ul>
<li v-for="product in products">
<!-- ... -->
<button @click="remove(product.id)">Remove</button>
</li>
</ul>
</template>
Is this pattern valid or considered bad practice? In a Twitter poll, 44% vs. 19% feel it is okay to return a Composable from a Composable call. I dug deeper into the matter in this blog post.
But what do you think? Let me know on Twitter or LinkedIn. I'm interested in your opinion on this.
Looking for a Vue Job?
Discover companies looking to hire Vue.js developers and connect with them on VueJobs, the leading job board for the Vue.js ecosystem.
Kamal
Docker has revolutionized how we think about deploying applications, promising a world where our containerized apps can run seamlessly anywhere. At least, that's the theory.
In practice, you must tailor your deployment strategy to your chosen cloud provider. Be it AWS, GCP, Azure, or something else.
Recently, I experimented with Kamal. And I find it amazing how straightforward things are using it. The Kamal configuration file feels like a docker-compose.yaml
, which I love for its simplicity when it comes to spinning up a local dev environment. With Kamal, you also get the same experience for your live deploys.
Combine Kamal with a Hetzner VPS, and you are set up to deploy Docker images to the Cloud in minutes.
What's your experience? Did you try out Kamal already? Or have you successfully moved a complex application from AWS to Azure, for example? How long did it take you? Join the discussion on LinkedIn!