How do you decide whether to use a library or write something yourself?
Frame it as a cost decision rather than a matter of taste. A dependency is not free — it carries bundle size, a security surface, and a maintenance obligation.
Reach for a library when: the problem is genuinely hard and well-specified, and getting it subtly wrong is dangerous. Date and timezone handling, cryptography, rich text editing, and virtualised lists all qualify.
Write it yourself when: you need a small fraction of what the library does, the whole thing is thirty lines, or the library's API forces your architecture in a direction you do not want.
Questions worth asking out loud in the interview:
- How large is it after tree-shaking, and does it ship to the browser or stay on the server?
- Is it actively maintained, and how many transitive dependencies come with it?
- How hard would it be to remove in a year?
Note: A strong closing line is that you would rather copy thirty lines into the codebase than take a dependency for them — a point made memorably by the left-pad incident.





