In frontend, composable means:
You can combine small pieces of logic or UI together to build something more complex.
Think LEGO blocks π§±.
1. Composable components
Instead of making one huge component:
UserPage
βββ header
βββ profile
βββ posts
βββ comments
βββ buttonsyou make smaller components:
UserPage
βββ Header
βββ Profile
βββ PostList
β βββ Post
βββ CommentList
βββ CommentThen you can reuse them:
Profile β UserPage
Profile β Sidebar
Profile β SettingsThatβs component composition.
2. Composable logic
This is especially common with Vue composables.
Suppose several components need authentication logic:
LoginPage
Dashboard
Navbar
SettingsInstead of putting authentication logic into each component, you create:
useAuth()Then:
const { user, login, logout } = useAuth()Each component can use the same logic.
useAuth()
/ | \
/ | \
Login Navbar DashboardThatβs composable logic.
Hook vs composable
The concepts are very similar:
| React | Vue |
|---|---|
| Hook | Composable |
useAuth() | useAuth() |
useFetch() | useFetch() |
useLocalStorage() | useLocalStorage() |
The terminology differs, but the idea is similar: extract reusable logic that can be combined and reused.
The important idea
When frontend developers say:
βMake this composable.β
They often mean:
Donβt put everything into one giant component. Break the logic/UI into small reusable pieces that can be combined.
For example:
β Huge component
UserDashboard
βββ authentication logic
βββ fetching logic
βββ pagination logic
βββ form logic
βββ notification logic
βββ UI
β
Composable design
UserDashboard
βββ useAuth()
βββ useUsers()
βββ usePagination()
βββ useForm()
βββ UI componentsSo the mental model is:
Composable = small, reusable pieces that can be combined to create larger functionality.