r/reactjs • u/salamazmlekom • 6d ago
Discussion Adapter over React hook forms
Those of you that use a form library in your react codebase. Do you tend to create an adapter over it or just use it directly? The reason I am asking is because I want to protect our codebase in case we need to shift to a different library at some point. It’s much easier to update the adapter in this case than it is to adjust the whole codebase (even with agents).
2
Upvotes
View all comments
1
u/worstallegation177 6d ago
An adapter's one of those things that feels like overkill until the day you actually need to swap libraries, and then you're the office hero. I've done it both ways. Direct usage is fine if you're on a small team and the lib is super stable, but if there's even a whisper of "what if we switch" in your planning meetings, just wrap the damn thing. The trick is keeping the abstraction thin enough that you're not rewriting the library yourself. Wrap the core methods you actually use, don't try to predict every edge case, and you'll save yourself a weekend of find-and-replace misery later.