Development
Framework Specific Development
All Frameworks
-
Set up your HTML head with some nice small tweaks
-
Use theme-colour and add your theme
<meta name="theme-color" content="#f00" />
-
The theme-color doesn’t have to be unique within the page. It can be personalized using the media attribute to change colors depending on the browser’s/computer’s configuration.
<!-- theme color is white unless in dark mode, then it's black --> <meta name="theme-color" content="#fff" /> <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#000" />
-
Add open graph meta tags - but note that the values should be page-specific and should be updated when navigating between pages.
<meta property="og:type" content="website"> <meta property="og:title" content="Page Title"> <meta property="og:description" content="Description of the page."> <meta property="og:url" content="link.to.be.displayed.when.shared"> <meta property="og:image" content="link.to.thumbnail.image"> <meta name="twitter:card" content="summary"> <meta name="twitter:title" content="Page Title"> <meta name="twitter:description" content="Description of the page."> <meta name="twitter:url" content="link.to.be.displayed.when.shared"> <meta name="twitter:image" content="link.to.thumbnail.image">
-
Add a favicon
-
-
Add smooth scrolling (in CSS file);
html { scroll-behavior: smooth; }
React
- 10 Best Practices in Front End Development
- (1) Use of Absolute Paths Instead of Relative Paths
- Change
import { Button } from '../../../../components/Button'
toimport { Button } from '@/components/Button'
- Change
- (4) Proper File Naming Conventions
- (1) Use of Absolute Paths Instead of Relative Paths
- 6 ways of getting data into React
- Use TanStack Router - https://tanstack.com/router/v1/docs/overview
- Optimizing React Performance
Vite
- Use TanStack Router - https://tanstack.com/router/v1/docs/overview
Next.js
- Removing Console Logs in Next.js
- Mastering Error and Loading pages
- Handling images in Next.js 14
- Adding unconfigured image hostname to next.config.js
- Top 12 Libraries for Your Next.js Project
- How to use CORS in Next.js 14
- A guide to caching in Next.js
- Advanced features of Next.js
- Things you didn't know about Next.js
CSS
Recommendations: (from Robin Wieruch)
CSS-in-CSS
-
CSS Modules - CSS Modules give you a way to encapsulate your CSS into component co-located modules. This way, styles don't leak accidentally into other components:
import styles from './style.module.css'; const Headline = ({ title }) => <h1 className={styles.headline}> {title} </h1>
Utility-First-CSS
- Tailwind CSS - https://tailwindcss.com/
const Headline = ({ title }) =>
<h1 className="text-blue-700">
{title}
</h1>
CSS-in-JS
Personally I'd not recommended runtime CSS-in-JS anymore due to performance and other problems in server-side environments
- Styled Components
- StyleX by Facebook
import styled from 'styled-components';
const BlueHeadline = styled.h1`
color: blue;
`;
const Headline = ({ title }) =>
<BlueHeadline>
{title}
</BlueHeadline>
Issues and Debugging
React Issues
- For issues in
React
(includingVite
andNext.JS
):-
General debugging - Debug React in VSCode
-
Issue 1 - Cannot be used as a JSX component
'SidebarItem' cannot be used as a JSX component. Its type '(props: SidebarLink) => Element' is not a valid JSX element type. Type '(props: SidebarLink) => Element' is not assignable to type '(props: any, deprecatedLegacyContext?: any) => ReactNode'. Type 'Element' is not assignable to type 'ReactNode'. Property 'children' is missing in type 'Element' but required in type 'ReactPortal'.
Solution link
-
HTML, CSS and JavaScript Issues
- If you are trying to minify JavaScript files and you get the error
Minify Failed: 'preserve_line' is not a supported option
, then run the command "Minify" again in VSCode usingCTRL + Shift + M
.- If this still fails, open user settings in VSCode, change a value in the minify section and try to save the file again to force the minification.
- Return the user settings options back once done.
Security and Authentication
Security
- Set up repository security scanning via Snyk
- Add the project to Snyk here
- Check and close off all vulnerabilities
Authentication
- Next.js
- NextAuth
- Auth0
- For other authentication, consider using the following resources;
Documentation
- Set up documentation for the project via a README.md file
- Write from scratch or use a template such as readme.so
Recommended Libraries
State Management
- Zustand - State management library - It allows you to manage global application state which can be read and modified by any React component that is connected to its store(s).
- Redux
Recommendations: (from Robin Wieruch)
- useState/useReducer for co-located or shared state
- opt-in useContext for enabling little global state
- Zustand (or an alternative) for lots of global state
Data Fetching
- TanStack Query (formerly known as React Query) -
yarn add @tanstack/react-query
- https://tanstack.com/query/latest- Works for both REST and GraphQL APIs
- Mastering React Query - A Complete Guide**
- Apollo Client -
yarn add @apollo/client
- https://www.apollographql.com/docs/react/- Works for GraphQL APIs
- RTK Query - If using Redux - https://redux-toolkit.js.org/rtk-query/overview
- tRPC - if you control the frontend and the backend (both TypeScript) - https://trpc.io/
- It can be combined with TanStack Query for all the niceties regarding data fetching while still being able to call your backend from your frontend by using typed functions.
Routing
- React Router - https://reactrouter.com/en/main
- TanStack Router - https://tanstack.com/router/v1/docs/overview
Components
- Material UI - Component Library -
yarn add @material-ui/core
- https://material-ui.com/ - shadcn/ui - https://ui.shadcn.com/
- saas-ui
- Getting started with SaaS UI is easy. First, you’ll have to install Chakra UI into your React project, then install SaaS UI, like this:
npm i @chakra-ui/react @emotion/react@¹¹ @emotion/styled@¹¹ framer-motion@⁶\
npm i @saas-ui/react
- If yarn is more your jam, you can do this instead:
yarn add @chakra-ui/react @emotion/react@¹¹ @emotion/styled@¹¹ framer-motion@⁶\
yarn add @saas-ui/react
Animations
In order of recommendation:
- Framer Motion - Animation library -
yarn add framer-motion
- https://www.framer.com/motion/ - React Spring - Animation library -
yarn add react-spring
- https://www.react-spring.io/ - 10 Best Animation Libraries
- React Flip Move - Animation library -
yarn add react-flip-move
- AOS - Animation library -
yarn add aos
- https://michalsnik.github.io/aos/ - Animista - Animation library (All CSS) - Animista
- Spinners Designs - just HTML and CSS
Charts
In order of recommendation:
- Recharts - https://recharts.org/en-US/
- Apex Charts - Charts Library -
yarn add apexcharts
- https://apexcharts.com/
Other Libraries
- React Libraries in 2024 - https://www.robinwieruch.de/react-libraries/
- UUIDv4 - Key management -
yarn add uuidv4
- https://www.npmjs.com/package/uuidv4import { v4 as uuid } from "uuid";
- Then use
key: uuid(),
- Web Analytics
- Google Analytics
- Umami
- GoatCounter
- Top 6 tools for Node.js monitoring
- Available APIs
- Application Notifications
- ntfy
- Novu In app notifications
- Other library links
- Email JS - send emails from your code without a backend server
- React Content Loader - SVG component to create placeholder loading, like Facebook cards loading or also known as skeleton UI
- React Spinners - Animation library -
yarn add react-spinners
- https://www.davidhu.io/react-spinners/ - React Toastify - Add quick success, failure, warning, info messages to the UI
- React Device Detect - Detect the device type (mobile, tablet, desktop) and OS (iOS, Android, Windows, Mac)
- React Error Catching
- Why Did You Render
- Review the full list of Coding resources on Todoist here
- Review the full list of React resources on Todoist here
Note - for more, see "Coding Resources" Todoist project
Other Tips and Easy Wins
- With the
accent-color
property you can specify the predominant color for checkboxes, radio buttons, ranges, and even progress bars. - Use the correct HTML
<input type="">
attribute for the correct input type. There are 22 HTML input types.