iTranslated by AI
My Favorite Frontend Tools 2023
I will write about the technology selection I make when performing frontend development in a team.
This is written with the premise of a service where logging in and handling individual user information is the main focus.
Approach
- Choose things with excellent maintainability
- Choose things with fewer restrictions
- Don't worry about unnecessary things
- Don't try to challenge too many new things at once
Framework
To be honest, lately, I've been choosing Next.js without question.
As I have a cautious personality, for products I am responsible for developing and operating, I choose Next.js because my experience with it is high and I can overcome many challenges with it.
Although there are some infrastructure constraints, being able to use SSG, SSR, and On-demand ISR on a per-page basis and benefiting from React's massive ecosystem is a huge advantage.
In terms of recruitment, it currently feels like there are more people who can work with React than with other frameworks.
As a second choice, I consider SPA frameworks like vanilla React, Vue3, Svelte, or Solid.js, assuming Cloudflare Workers is placed in front.
If I were told it's okay to fail and use experimental technologies, I might consider SvelteKit, Qwik, or a configuration based on Cloudflare Workers Service Bindings.
For other types of systems
For sites assuming SSG, I would use Astro; for large-scale systems, I would consider micro-frontends.
Build Tools
volta
I use volta for Node.js version management.
While there are pros and cons to using volta, I like it because it can be used on macOS, Windows, Linux, and in CIs like GitHub Actions.
Concerns include it not being usable in some CIs and the potential for conflicts with people using other tools.
If a better tool than volta is proposed, I am open to accepting it.
yarn
I often use yarn v1.
There's no specific reason.
I use it because I haven't encountered any particular trouble with it.
I'm explicitly stating this to make it clear that I haven't thought deeply about it.
TypeScript
I always use it.
I make the tsconfig settings as strict as possible and configure aliases for the src directory.
ESLint/Prettier
I always use them.
For ESLint, I configure settings like import/order.
I commit the editor config and enforce code formatting with Prettier on file save.
I check linting and builds in the CI.
While I sometimes check on pre-commit, I'm of the opinion that checking in the CI is sufficient, so I don't actively push for it.
UI Framework
Basically, I do not use one.
I consider using them for things like admin panels where high design quality is not required.
Candidates
- Ant Design
- Chakra UI
- daisyUI
- and others
CSS
Basically, as long as I can apply styles scoped to components following a style guide, Utility First frameworks feel suitable.
Tailwind feels mature among Utility First frameworks, so I don't consider other frameworks unless there is a strong preference.
CSS Modules also fit the requirements, but I don't choose them often because defining custom CSS variables and handling responsiveness is tedious.
If the design has unique features like heavy use of gradients or if I'm using ShadowDOM, I might not adopt Tailwind.
Test
As a premise, I design the system to write as little business logic as possible on the frontend.
Even so, I write tests with Jest for code that inevitably has to be handled on the frontend.
It might not strictly be testing, but I use Storybook for UI verification.
Sometimes I also write regression tests using Cypress, Autify, etc.
Storybook
- I create stories according to the state for components responsible for the UI.
- However, for generic components, since the number of combinations increases exponentially, I make them verifiable through Storybook props.
- For components that depend on an API, I mock the API with MSW and create stories for each API response.
- When using OpenAPI, I feed the examples defined in the OpenAPI schema into the MSW response and create stories based on those units.
API
I always adopt schema-first development. It is inefficient to imagine the API implementation or wait for the implementation before starting frontend development. Unless there is a reason to use something else, I adopt OpenAPI. I also use the examples defined in OpenAPI within Storybook. While gRPC or GraphQL could be adopted, they increase the technical considerations, so I often don't choose them unless there is a significant benefit.
Form Library
I use react-hook-form. I use Zod for validation. Both are convenient, but it gets difficult when trying to do complex things...
API Calling
I generate typescript-axios code from the OpenAPI schema. I then reference and use the generated code from React Query. React Query is convenient, but handling keys and other aspects can be difficult and sometimes leads to a struggle when trying to do complex things...
About aspida
I have used aspida before, but in a previous version, it generated code that didn't follow the OpenAPI specification, so I haven't used it actively since then. It has likely been improved by now, and since I like the code it generates, I would like to use it again.
Revision History
- Title changed
Discussion