The Journey of #100DaysOfCode (@Ayman_Dandan)

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ of #100DaysOfCode

  • ๐‘ฑ๐‘พ๐‘ป ๐‘จ๐’–๐’•๐’‰๐’†๐’๐’•๐’Š๐’„๐’‚๐’•๐’Š๐’๐’ ๐’‚๐’๐’… ๐‘บ๐’•๐’๐’“๐’‚๐’ˆ๐’† -

When a user logs in, they are typically issued a JWT (JSON Web Token) for authentication. But how do you securely store and manage these tokens?

For most applications, JWTs are stored in ๐ฅ๐จ๐œ๐š๐ฅ๐’๐ญ๐จ๐ซ๐š๐ ๐ž (not preferred) or ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ. Storing them in cookies has added security benefits, like being HTTP-only and secure when paired with HTTPS.

The attached snippet is a basic example of generating and sending a JWT.

This token can then be sent with each request to authenticate users.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ of #100DaysOfCode

  • ๐‘ผ๐’”๐’Š๐’๐’ˆ ๐‘ช๐’๐’๐’Œ๐’Š๐’†๐’” ๐’•๐’ ๐‘บ๐’•๐’๐’“๐’† ๐‘ฑ๐‘พ๐‘ป๐’” (๐‘ญ๐’“๐’๐’๐’•๐’†๐’๐’… + ๐‘ฉ๐’‚๐’„๐’Œ๐’†๐’๐’…) -

Cookies are a great way to securely store JWT tokens because they can be marked as ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ, preventing client-side JavaScript from accessing them. Hereโ€™s a quick rundown of how you can store and retrieve JWT tokens using cookies.

๐๐š๐œ๐ค๐ž๐ง๐: On the backend, include the JWT token in the res.cookie

๐…๐ซ๐จ๐ง๐ญ๐ž๐ง๐: On the frontend, when making authenticated requests, the browser will automatically include the cookie in the request headers.

By using cookies, you avoid exposing the token to XSS attacks, keeping your application more secure.
1726662593896

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ‘ of 100daysofcode

  • ๐‘จ๐’„๐’„๐’†๐’”๐’” ๐‘ป๐’๐’Œ๐’†๐’๐’” & ๐‘น๐’†๐’‡๐’“๐’†๐’”๐’‰ ๐‘ป๐’๐’Œ๐’†๐’๐’” -

When building a secure authentication system, ๐‘จ๐’„๐’„๐’†๐’”๐’” ๐‘ป๐’๐’Œ๐’†๐’๐’” and ๐‘น๐’†๐’‡๐’“๐’†๐’”๐’‰ ๐‘ป๐’๐’Œ๐’†๐’๐’” are essential components that help you manage user sessions. Letโ€™s break down what these tokens are and why using ๐‘ฏ๐‘ป๐‘ป๐‘ท-๐’๐’๐’๐’š ๐’„๐’๐’๐’Œ๐’Š๐’†๐’” to store them enhances security.

โ†’ ๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—ฎ๐—ป ๐—”๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป?
An ๐‘จ๐’„๐’„๐’†๐’”๐’” ๐‘ป๐’๐’Œ๐’†๐’ is a ๐˜ด๐˜ฉ๐˜ฐ๐˜ณ๐˜ต-๐˜ญ๐˜ช๐˜ท๐˜ฆ๐˜ฅ ๐˜ต๐˜ฐ๐˜ฌ๐˜ฆ๐˜ฏ (often in the form of a JWT, JSON Web Token) that allows users to access protected resources. Once a user logs in, the server generates an access token and provides it to the client. The token is then used to authorize API requests. It typically expires after a short period (15 minutes to an hour) for security purposes.

โ†’ ๐—ช๐—ต๐—ฎ๐˜ ๐—ถ๐˜€ ๐—ฎ ๐—ฅ๐—ฒ๐—ณ๐—ฟ๐—ฒ๐˜€๐—ต ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป?
A ๐‘น๐’†๐’‡๐’“๐’†๐’”๐’‰ ๐‘ป๐’๐’Œ๐’†๐’ is a ๐˜ญ๐˜ฐ๐˜ฏ๐˜จ-๐˜ญ๐˜ช๐˜ท๐˜ฆ๐˜ฅ ๐˜ต๐˜ฐ๐˜ฌ๐˜ฆ๐˜ฏ thatโ€™s used to obtain a new access token after the original one expires. This way, users donโ€™t have to log in again after their access token expires. Instead, they can refresh their session using the refresh token to get a new access token.

๐—ช๐—ต๐˜† ๐—จ๐˜€๐—ฒ ๐—”๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ฅ๐—ฒ๐—ณ๐—ฟ๐—ฒ๐˜€๐—ต ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป๐˜€?
โ†’ ๐’๐ž๐œ๐ฎ๐ซ๐ข๐ญ๐ฒ: By having short-lived access tokens, you minimize the risk of an attacker misusing a stolen token.
โ†’ ๐’๐ž๐š๐ฆ๐ฅ๐ž๐ฌ๐ฌ ๐”๐ฌ๐ž๐ซ ๐„๐ฑ๐ฉ๐ž๐ซ๐ข๐ž๐ง๐œ๐ž: With refresh tokens, users can continue to use the app without constantly re-entering their credentials after the access token expires.

The combination of ๐ฌ๐ก๐จ๐ซ๐ญ-๐ฅ๐ข๐ฏ๐ž๐ ๐š๐œ๐œ๐ž๐ฌ๐ฌ ๐ญ๐จ๐ค๐ž๐ง๐ฌ and ๐ฅ๐จ๐ง๐ -๐ฅ๐ข๐ฏ๐ž๐ ๐ซ๐ž๐Ÿ๐ซ๐ž๐ฌ๐ก ๐ญ๐จ๐ค๐ž๐ง๐ฌ helps balance security with convenience.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ’ of 100daysofcode

  • ๐‘พ๐’‰๐’š ๐‘บ๐’•๐’๐’“๐’† ๐‘ป๐’๐’Œ๐’†๐’๐’” ๐’Š๐’ ๐‘ฏ๐‘ป๐‘ป๐‘ท-๐‘ถ๐’๐’๐’š ๐‘ช๐’๐’๐’Œ๐’Š๐’†๐’”? -

HTTP-only cookies are cookies that canโ€™t be accessed via JavaScript, making them a highly secure way to store sensitive data like access and refresh tokens. Hereโ€™s why you should store your tokens in ๐‘ฏ๐‘ป๐‘ป๐‘ท-๐’๐’๐’๐’š ๐’„๐’๐’๐’Œ๐’Š๐’†๐’”:

  1. ๐๐ซ๐จ๐ญ๐ž๐œ๐ญ๐ฌ ๐€๐ ๐š๐ข๐ง๐ฌ๐ญ ๐—๐’๐’ ๐€๐ญ๐ญ๐š๐œ๐ค๐ฌ: Since the cookies canโ€™t be accessed by JavaScript, attackers wonโ€™t be able to steal tokens through XSS vulnerabilities.
  2. ๐€๐ฎ๐ญ๐จ๐ฆ๐š๐ญ๐ข๐œ ๐“๐ซ๐š๐ง๐ฌ๐ฆ๐ข๐ฌ๐ฌ๐ข๐จ๐ง: Cookies are automatically included in every request made to the server, so you donโ€™t need to manually add tokens to request headers.
  3. ๐๐ซ๐ž๐ฏ๐ž๐ง๐ญ ๐‚๐ฅ๐ข๐ž๐ง๐ญ-๐’๐ข๐๐ž ๐’๐ญ๐จ๐ซ๐š๐ ๐ž ๐ˆ๐ฌ๐ฌ๐ฎ๐ž๐ฌ: Storing tokens in localStorage or sessionStorage exposes them to potential XSS attacks. Using HTTP-only cookies avoids this risk.

By using HTTP-only cookies, your tokens are kept safe from client-side attacks and are automatically sent with requests, improving both security and usability.

Stay tuned for the next post, where weโ€™ll go into the details of how to implement access tokens and refresh tokens using HTTP-only cookies!

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ“ of #100DaysOfCode

  • ๐‘ฏ๐’๐’˜ ๐’•๐’ ๐‘บ๐’†๐’• ๐‘จ๐’„๐’„๐’†๐’”๐’” ๐’‚๐’๐’… ๐‘น๐’†๐’‡๐’“๐’†๐’”๐’‰ ๐‘ป๐’๐’Œ๐’†๐’๐’” ๐‘ผ๐’”๐’Š๐’๐’ˆ ๐‘ฏ๐‘ป๐‘ป๐‘ท-๐‘ถ๐’๐’๐’š ๐‘ช๐’๐’๐’Œ๐’Š๐’†๐’” (๐‘ฉ๐’‚๐’„๐’Œ๐’†๐’๐’…) -

In the previous posts, we covered why using ๐š๐œ๐œ๐ž๐ฌ๐ฌ ๐ญ๐จ๐ค๐ž๐ง๐ฌ and ๐ซ๐ž๐Ÿ๐ซ๐ž๐ฌ๐ก ๐ญ๐จ๐ค๐ž๐ง๐ฌ stored in ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ enhances security. Now, letโ€™s dive into how to set up this authentication system on your ๐›๐š๐œ๐ค๐ž๐ง๐.

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿญ: ๐—š๐—ฒ๐—ป๐—ฒ๐—ฟ๐—ฎ๐˜๐—ถ๐—ป๐—ด ๐—”๐—ฐ๐—ฐ๐—ฒ๐˜€๐˜€ ๐—ฎ๐—ป๐—ฑ ๐—ฅ๐—ฒ๐—ณ๐—ฟ๐—ฒ๐˜€๐—ต ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป๐˜€
When a user logs in, youโ€™ll generate both an access token and a refresh token. For this example, weโ€™ll use ๐‰๐–๐“ (๐‰๐’๐Ž๐ ๐–๐ž๐› ๐“๐จ๐ค๐ž๐ง๐ฌ). The access token will have a short expiration time, while the refresh token will last much longer.

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฎ: ๐—ฆ๐—ฒ๐—ป๐—ฑ๐—ถ๐—ป๐—ด ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป๐˜€ ๐—ถ๐—ป ๐—›๐—ง๐—ง๐—ฃ-๐—ข๐—ป๐—น๐˜† ๐—–๐—ผ๐—ผ๐—ธ๐—ถ๐—ฒ๐˜€
Once youโ€™ve generated the tokens, youโ€™ll send them to the client as ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ. This ensures theyโ€™re automatically sent with each request and protected from JavaScript access.
โ†’ ๐ก๐ญ๐ญ๐ฉ๐Ž๐ง๐ฅ๐ฒ: ๐ญ๐ซ๐ฎ๐ž ensures that the cookie canโ€™t be accessed via JavaScript.
โ†’ ๐ฌ๐ž๐œ๐ฎ๐ซ๐ž: ๐ญ๐ซ๐ฎ๐ž ensures the cookie is only sent over HTTPS in production.
โ†’ ๐ฌ๐š๐ฆ๐ž๐’๐ข๐ญ๐ž: โ€˜๐’๐ญ๐ซ๐ข๐œ๐ญโ€™ helps prevent CSRF attacks by making sure cookies are only sent to your domain.

๐—ฆ๐˜๐—ฒ๐—ฝ ๐Ÿฏ: ๐—›๐—ฎ๐—ป๐—ฑ๐—น๐—ถ๐—ป๐—ด ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป ๐—ฅ๐—ฒ๐—ณ๐—ฟ๐—ฒ๐˜€๐—ต๐—ฒ๐˜€
When the access token expires, the frontend can send a request to your ๐ซ๐ž๐Ÿ๐ซ๐ž๐ฌ๐ก ๐ญ๐จ๐ค๐ž๐ง ๐ž๐ง๐๐ฉ๐จ๐ข๐ง๐ญ to get a new access token. Youโ€™ll verify the refresh token and generate a new access token if itโ€™s valid.

With this setup, the client can seamlessly get new access tokens when needed, all while keeping tokens secure in ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ.

Next, weโ€™ll cover how to ๐š๐œ๐œ๐ž๐ฌ๐ฌ ๐ญ๐ก๐ž๐ฌ๐ž ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ from the frontend and ensure your authentication system is working smoothly.
1727609848081
1727609848241

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ” of #100DaysOfCode

  • ๐‘จ๐’„๐’„๐’†๐’”๐’”๐’Š๐’๐’ˆ ๐‘ป๐’๐’Œ๐’†๐’๐’” ๐’Š๐’ ๐‘ฏ๐‘ป๐‘ป๐‘ท-๐‘ถ๐’๐’๐’š ๐‘ช๐’๐’๐’Œ๐’Š๐’†๐’” (๐‘ญ๐’“๐’๐’๐’•๐’†๐’๐’…) -

Now that you know how to generate and store ๐š๐œ๐œ๐ž๐ฌ๐ฌ ๐ญ๐จ๐ค๐ž๐ง๐ฌ ๐š๐ง๐ ๐ซ๐ž๐Ÿ๐ซ๐ž๐ฌ๐ก ๐ญ๐จ๐ค๐ž๐ง๐ฌ using ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ, letโ€™s see how to access and use these tokens on the frontend.

โ†’ ๐—”๐˜‚๐˜๐—ผ๐—บ๐—ฎ๐˜๐—ถ๐—ฐ ๐—ง๐—ฟ๐—ฎ๐—ป๐˜€๐—บ๐—ถ๐˜€๐˜€๐—ถ๐—ผ๐—ป ๐—ผ๐—ณ ๐—–๐—ผ๐—ผ๐—ธ๐—ถ๐—ฒ๐˜€
One of the key advantages of using ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ is that the browser automatically sends them with every request to your backend. You donโ€™t need to manually attach the token to your headers like you would if you were storing the token in localStorage.

In the attached snippet, ๐ฐ๐ข๐ญ๐ก๐‚๐ซ๐ž๐๐ž๐ง๐ญ๐ข๐š๐ฅ๐ฌ: ๐ญ๐ซ๐ฎ๐ž is crucial here. It ensures that cookies are included with the request.

โ†’ ๐— ๐—ฎ๐—ธ๐—ถ๐—ป๐—ด ๐—ฎ ๐—ง๐—ผ๐—ธ๐—ฒ๐—ป ๐—ฅ๐—ฒ๐—ณ๐—ฟ๐—ฒ๐˜€๐—ต ๐—ฅ๐—ฒ๐—พ๐˜‚๐—ฒ๐˜€๐˜
If the access token expires, your frontend can send a request to the ๐ซ๐ž๐Ÿ๐ซ๐ž๐ฌ๐ก ๐ญ๐จ๐ค๐ž๐ง ๐ž๐ง๐๐ฉ๐จ๐ข๐ง๐ญ to get a new access token. Since the refresh token is stored in an HTTP-only cookie, the browser will automatically send it along with the request.

โ†’ ๐—•๐—ฒ๐—ป๐—ฒ๐—ณ๐—ถ๐˜๐˜€ ๐—ผ๐—ณ ๐—จ๐˜€๐—ถ๐—ป๐—ด ๐—›๐—ง๐—ง๐—ฃ-๐—ข๐—ป๐—น๐˜† ๐—–๐—ผ๐—ผ๐—ธ๐—ถ๐—ฒ๐˜€ ๐—ผ๐—ป ๐˜๐—ต๐—ฒ ๐—™๐—ฟ๐—ผ๐—ป๐˜๐—ฒ๐—ป๐—ฑ

  1. ๐€๐ฎ๐ญ๐จ๐ฆ๐š๐ญ๐ข๐œ ๐Œ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ: Cookies are automatically included with every request to your server, so you donโ€™t need to manually add the token to headers.
  2. ๐’๐ž๐œ๐ฎ๐ซ๐ข๐ญ๐ฒ: Since the tokens are stored in ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ, they canโ€™t be accessed or modified by client-side JavaScript, making them more secure than tokens stored in localStorage.

By using ๐‡๐“๐“๐-๐จ๐ง๐ฅ๐ฒ ๐œ๐จ๐จ๐ค๐ข๐ž๐ฌ for tokens, your frontend can focus on making API requests without worrying about managing tokens manually, while keeping your authentication system more secure.

Now your app is ready to handle ๐ฌ๐ž๐œ๐ฎ๐ซ๐ž, ๐ฌ๐ž๐š๐ฆ๐ฅ๐ž๐ฌ๐ฌ ๐š๐ฎ๐ญ๐ก๐ž๐ง๐ญ๐ข๐œ๐š๐ญ๐ข๐จ๐ง!

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ• of #100DaysOfCode

  • ๐‘บ๐’•๐’“๐’–๐’„๐’•๐’–๐’“๐’Š๐’๐’ˆ ๐’€๐’๐’–๐’“ ๐‘น๐’†๐’‚๐’„๐’• ๐‘ช๐’๐’Ž๐’‘๐’๐’๐’†๐’๐’•๐’” ๐’‡๐’๐’“ ๐‘บ๐’„๐’‚๐’๐’‚๐’ƒ๐’Š๐’๐’Š๐’•๐’š -

After finishing up with the backend tips, weโ€™re moving to the ๐Ÿ๐ซ๐จ๐ง๐ญ๐ž๐ง๐ side of things. One of the key factors for a scalable, maintainable frontend is how you structure your components. Proper organization will help as your project grows, especially when working in teams or handling multiple features.

A good strategy is to separate reusable UI components (e.g., buttons, inputs) from domain-specific components (e.g., login, dashboard). This makes your project modular, improving maintainability and scalability.

By grouping reusable and feature-specific components, youโ€™ll streamline development and prevent clutter as your app expands.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ– of #100DaysOfCode

  • ๐‘ช๐’๐’…๐’† ๐‘บ๐’‘๐’๐’Š๐’•๐’•๐’Š๐’๐’ˆ ๐’˜๐’Š๐’•๐’‰ ๐‘น๐’†๐’‚๐’„๐’• ๐‘น๐’๐’–๐’•๐’†๐’“ ๐‘ซ๐‘ถ๐‘ด ๐’‡๐’๐’“ ๐‘ญ๐’‚๐’”๐’•๐’†๐’“ ๐‘ณ๐’๐’‚๐’… ๐‘ป๐’Š๐’Ž๐’†๐’” -

As your app grows, youโ€™ll likely notice slower initial load times. This happens because all of your components are loaded at once, even if the user doesnโ€™t need them immediately. ๐‚๐จ๐๐ž ๐ฌ๐ฉ๐ฅ๐ข๐ญ๐ญ๐ข๐ง๐  allows you to load parts of your app dynamically, improving performance by reducing the bundle size.

React Router DOM supports code splitting through dynamic imports (using ๐ฅ๐š๐ณ๐ฒ() and ๐’๐ฎ๐ฌ๐ฉ๐ž๐ง๐ฌ๐ž). This technique ensures that only the code needed for the current route is loaded, reducing initial load times and improving performance.

โ†’ ๐–๐ก๐ฒ: It keeps your app responsive by only loading code when itโ€™s needed.
โ†’ ๐–๐ก๐ž๐ง: Use it when your app has large, less frequently used components (e.g., admin panels, detailed reports, or any feature-heavy routes). This is especially useful in Single Page Applications (SPAs), where users might not need all routes loaded upfront.
1728032846640

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ–๐Ÿ— of #100DaysOfCode

  • ๐‘ช๐’–๐’”๐’•๐’๐’Ž๐’Š๐’›๐’Š๐’๐’ˆ ๐‘ด๐’‚๐’•๐’†๐’“๐’Š๐’‚๐’ ๐‘ผ๐‘ฐ ๐‘ป๐’‰๐’†๐’Ž๐’†๐’” ๐’‡๐’๐’“ ๐‘ช๐’๐’๐’”๐’Š๐’”๐’•๐’†๐’๐’• ๐‘ฉ๐’“๐’‚๐’๐’…๐’Š๐’๐’ˆ -

Having a consistent design across your app is essential for good user experience and reinforcing your brand identity. Material UI offers ๐ญ๐ก๐ž๐ฆ๐ข๐ง๐  capabilities that let you customize the look and feel of your app globally โ€” from color schemes to typography and spacing.

Using ๐“๐ก๐ž๐ฆ๐ž๐๐ซ๐จ๐ฏ๐ข๐๐ž๐ซ, you ensure that your entire app follows the same design rules, which simplifies updates and makes your app look more professional.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐ŸŽ of #100DaysOfCode

  • ๐‘ฌ๐’‡๐’‡๐’Š๐’„๐’Š๐’†๐’๐’• ๐‘ซ๐’‚๐’•๐’‚ ๐‘ญ๐’†๐’•๐’„๐’‰๐’Š๐’๐’ˆ ๐’˜๐’Š๐’•๐’‰ ๐‘จ๐’™๐’Š๐’๐’” ๐’‚๐’๐’… ๐‘ฌ๐’“๐’“๐’๐’“ ๐‘ฏ๐’‚๐’๐’…๐’๐’Š๐’๐’ˆ -

In React, fetching data from an API is a common task, and ๐€๐ฑ๐ข๐จ๐ฌ makes it easy. Using useEffect, you can fetch data and store it in a componentโ€™s state, but itโ€™s important to handle errors gracefully to prevent app crashes.

๐–๐ก๐ฒ: It helps you easily manage API calls and errors.
๐–๐ก๐ž๐ง: Use it whenever you need to fetch data from an external API or your backend, ensuring you provide proper error feedback to your users.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ of #100DaysOfCode

  • ๐‘ฉ๐’–๐’Š๐’๐’…๐’Š๐’๐’ˆ ๐‘ญ๐’๐’“๐’Ž๐’” ๐’˜๐’Š๐’•๐’‰ ๐‘ด๐’‚๐’•๐’†๐’“๐’Š๐’‚๐’ ๐‘ผ๐‘ฐโ€™๐’” ๐‘ญ๐’๐’“๐’Ž๐‘ช๐’๐’๐’•๐’“๐’๐’, ๐‘ฉ๐’๐’™, ๐’‚๐’๐’… ๐‘ญ๐’๐’“๐’Ž๐‘ณ๐’‚๐’ƒ๐’†๐’ -

Building forms can be tricky, but Material UIโ€™s ๐…๐จ๐ซ๐ฆ๐‚๐จ๐ง๐ญ๐ซ๐จ๐ฅ, ๐๐จ๐ฑ, and ๐…๐จ๐ซ๐ฆ๐‹๐š๐›๐ž๐ฅ give you flexibility in layout and ensure accessibility standards are met.

By using ๐…๐จ๐ซ๐ฆ๐‹๐š๐›๐ž๐ฅ alongside ๐…๐จ๐ซ๐ฆ๐‚๐จ๐ง๐ญ๐ซ๐จ๐ฅ, you make your forms both accessible and user-friendly. The layout is easily customizable using ๐๐จ๐ฑ.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ of #100DaysOfCode

  • ๐‘ถ๐’‘๐’•๐’Š๐’Ž๐’Š๐’›๐’Š๐’๐’ˆ ๐‘บ๐’•๐’‚๐’•๐’† ๐‘ด๐’‚๐’๐’‚๐’ˆ๐’†๐’Ž๐’†๐’๐’• ๐’˜๐’Š๐’•๐’‰ ๐’–๐’”๐’†๐‘น๐’†๐’…๐’–๐’„๐’†๐’“ -
    ๐˜ž๐˜ฉ๐˜ฆ๐˜ฏ ๐˜ต๐˜ฐ ๐˜œ๐˜ด๐˜ฆ ๐˜ถ๐˜ด๐˜ฆ๐˜™๐˜ฆ๐˜ฅ๐˜ถ๐˜ค๐˜ฆ๐˜ณ ๐˜–๐˜ท๐˜ฆ๐˜ณ ๐˜ถ๐˜ด๐˜ฆ๐˜š๐˜ต๐˜ข๐˜ต๐˜ฆ

For simple states, ๐ฎ๐ฌ๐ž๐’๐ญ๐š๐ญ๐ž is often enough. However, for more complex states that involve multiple sub-values or state transitions, ๐ฎ๐ฌ๐ž๐‘๐ž๐๐ฎ๐œ๐ž๐ซ offers a cleaner and more maintainable approach.

โ†’ ๐–๐ก๐ฒ ๐”๐ฌ๐ž ๐ˆ๐ญ: Itโ€™s ideal when managing complex state logic (e.g., forms, nested objects).
โ†’ ๐–๐ก๐ž๐ง ๐ญ๐จ ๐”๐ฌ๐ž ๐ˆ๐ญ: When state logic involves multiple related values or complex transitions, ๐ฎ๐ฌ๐ž๐‘๐ž๐๐ฎ๐œ๐ž๐ซ offers better clarity and maintainability.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ‘ of #100DaysOfCode

  • ๐‘ต๐’Š๐’—๐’ ๐‘ป๐’“๐’†๐’† ๐‘ช๐’‰๐’‚๐’“๐’•๐’” ๐’‡๐’๐’“ ๐‘ซ๐’‚๐’•๐’‚ ๐‘ฝ๐’Š๐’”๐’–๐’‚๐’๐’Š๐’›๐’‚๐’•๐’Š๐’๐’ -

If youโ€™re dealing with hierarchical data, ๐๐ข๐ฏ๐จ ๐“๐ซ๐ž๐ž ๐‚๐ก๐š๐ซ๐ญ๐ฌ can help you display it in an intuitive and interactive way. This type of chart is great for representing organizational structures, file systems, or any nested data.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ’ of #100DaysOfCode

  • ๐‘ต๐’Š๐’—๐’ ๐‘ฉ๐’‚๐’“ ๐’‚๐’๐’… ๐‘ท๐’Š๐’† ๐‘ช๐’‰๐’‚๐’“๐’•๐’” ๐’‡๐’๐’“ ๐‘ซ๐’‚๐’•๐’‚ ๐‘ฝ๐’Š๐’”๐’–๐’‚๐’๐’Š๐’›๐’‚๐’•๐’Š๐’๐’ -

In addition to tree charts, ๐๐ข๐ฏ๐จ also provides ๐๐š๐ซ and ๐๐ข๐ž Charts for summarizing trends and categories in your data. Bar charts are great for comparisons, while pie charts show proportions.


2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ“ of #100DaysOfCode

  • ๐‘ต๐’Š๐’—๐’ ๐‘น๐’‚๐’…๐’‚๐’“ ๐‘ช๐’‰๐’‚๐’“๐’• ๐’‡๐’๐’“ ๐‘ด๐’–๐’๐’•๐’Š๐’…๐’Š๐’Ž๐’†๐’๐’”๐’Š๐’๐’๐’‚๐’ ๐‘ซ๐’‚๐’•๐’‚ -

๐๐ข๐ฏ๐จ ๐‘๐š๐๐š๐ซ ๐‚๐ก๐š๐ซ๐ญ๐ฌ are perfect for visualizing multidimensional data like performance metrics, skill levels, or comparison between different entities. This type of chart is useful for showing strengths and weaknesses across various categories.
1728042704413

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ” of #100DaysOfCode

  • ๐‘ผ๐’”๐’Š๐’๐’ˆ ๐‘พ๐’๐’“๐’Œ๐’†๐’“ ๐‘ป๐’‰๐’“๐’†๐’‚๐’…๐’” ๐’‡๐’๐’“ ๐‘ฏ๐’†๐’‚๐’—๐’š ๐‘ณ๐’Š๐’‡๐’•๐’Š๐’๐’ˆ -
    ๐˜ž๐˜ฉ๐˜ข๐˜ต ๐˜ช๐˜ด ๐˜ข ๐˜ž๐˜ฐ๐˜ณ๐˜ฌ๐˜ฆ๐˜ณ ๐˜›๐˜ฉ๐˜ณ๐˜ฆ๐˜ข๐˜ฅ?

When your app performs complex computations or processes large datasets, you may experience a frozen UI. This happens because JavaScript is single-threaded, meaning long-running tasks block the main thread. ๐–๐จ๐ซ๐ค๐ž๐ซ ๐ญ๐ก๐ซ๐ž๐š๐๐ฌ (or Web Workers) solve this by moving heavy operations off the main thread, keeping the UI responsive.

โ†’ ๐–๐ก๐ฒ ๐”๐ฌ๐ž ๐ˆ๐ญ: Offload heavy computations to improve performance.
โ†’ ๐–๐ก๐ž๐ง ๐ญ๐จ ๐”๐ฌ๐ž ๐ˆ๐ญ: Whenever your app has computationally expensive tasks like large data manipulation, image processing, or running algorithms in the background.
1728042997453

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ• of #100DaysOfCode

  • ๐‘ท๐’†๐’“๐’‡๐’๐’“๐’Ž๐’‚๐’๐’„๐’† ๐‘ถ๐’‘๐’•๐’Š๐’Ž๐’Š๐’›๐’‚๐’•๐’Š๐’๐’ ๐’˜๐’Š๐’•๐’‰ ๐‘น๐’†๐’‚๐’„๐’•.๐’Ž๐’†๐’Ž๐’ ๐’‚๐’๐’… ๐’–๐’”๐’†๐‘ด๐’†๐’Ž๐’ -
    ๐˜—๐˜ณ๐˜ฆ๐˜ท๐˜ฆ๐˜ฏ๐˜ต๐˜ช๐˜ฏ๐˜จ ๐˜œ๐˜ฏ๐˜ฏ๐˜ฆ๐˜ค๐˜ฆ๐˜ด๐˜ด๐˜ข๐˜ณ๐˜บ ๐˜™๐˜ฆ๐˜ฏ๐˜ฅ๐˜ฆ๐˜ณ๐˜ด ๐˜ช๐˜ฏ ๐˜™๐˜ฆ๐˜ข๐˜ค๐˜ต

React gives you two powerful tools for optimizing performance: ๐‘๐ž๐š๐œ๐ญ.๐ฆ๐ž๐ฆ๐จ and ๐ฎ๐ฌ๐ž๐Œ๐ž๐ฆ๐จ.

โ†’ ๐‘๐ž๐š๐œ๐ญ.๐ฆ๐ž๐ฆ๐จ: Prevents a component from re-rendering unless its props change.
โ†’ ๐ฎ๐ฌ๐ž๐Œ๐ž๐ฆ๐จ: Memoizes expensive computations, only re-calculating them when dependencies change.

โ†’ ๐–๐ก๐ž๐ง ๐ญ๐จ ๐”๐ฌ๐ž ๐ˆ๐ญ: Use ๐‘๐ž๐š๐œ๐ญ.๐ฆ๐ž๐ฆ๐จ for components that frequently re-render unnecessarily, and ๐ฎ๐ฌ๐ž๐Œ๐ž๐ฆ๐จ for expensive computations.
โ†’ ๐–๐ก๐ฒ ๐”๐ฌ๐ž ๐ˆ๐ญ: It helps improve performance, especially in apps with lots of complex components.
1728043409999

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ– of #100DaysOfCode

  • ๐‘ป๐’‰๐’† ๐‘ท๐’๐’˜๐’†๐’“ ๐’๐’‡ ๐‘ฐ๐’๐’•๐’†๐’ˆ๐’“๐’‚๐’•๐’Š๐’๐’ โ€“ ๐‘ช๐’๐’๐’๐’†๐’„๐’•๐’Š๐’๐’ˆ ๐’•๐’‰๐’† ๐‘ญ๐’–๐’๐’ ๐‘ด๐‘ฌ๐‘น๐‘ต ๐‘บ๐’•๐’‚๐’„๐’Œ -
    ๐˜‰๐˜ณ๐˜ช๐˜ฏ๐˜จ๐˜ช๐˜ฏ๐˜จ ๐˜›๐˜ฐ๐˜จ๐˜ฆ๐˜ต๐˜ฉ๐˜ฆ๐˜ณ ๐˜”๐˜ฐ๐˜ฏ๐˜จ๐˜ฐ๐˜‹๐˜‰, ๐˜Œ๐˜น๐˜ฑ๐˜ณ๐˜ฆ๐˜ด๐˜ด, ๐˜™๐˜ฆ๐˜ข๐˜ค๐˜ต, ๐˜ข๐˜ฏ๐˜ฅ ๐˜•๐˜ฐ๐˜ฅ๐˜ฆ

After taking a short 3-day break to reflect on the journey so far, itโ€™s time to get back into the flow. Weโ€™ve covered a lot, from understanding each layer of the MERN stack to the intricacies of frontend and backend development. Now, letโ€™s focus on the ๐ฉ๐จ๐ฐ๐ž๐ซ ๐จ๐Ÿ ๐ข๐ง๐ญ๐ž๐ ๐ซ๐š๐ญ๐ข๐จ๐งโ€”bringing all the parts together into a cohesive, full-stack project.

Full-stack development isnโ€™t just about building isolated pieces; itโ€™s about ensuring smooth integration between the client-side ๐‘๐ž๐š๐œ๐ญ ๐š๐ฉ๐ฉ, the backend APIs served by ๐„๐ฑ๐ฉ๐ซ๐ž๐ฌ๐ฌ.๐ฃ๐ฌ, ๐Œ๐จ๐ง๐ ๐จ๐ƒ๐ as the database, and ๐๐จ๐๐ž.๐ฃ๐ฌ tying it all together.

๐—ž๐—ฒ๐˜† ๐—ฆ๐˜๐—ฒ๐—ฝ๐˜€ ๐˜๐—ผ ๐—™๐˜‚๐—น๐—น ๐— ๐—˜๐—ฅ๐—ก ๐—œ๐—ป๐˜๐—ฒ๐—ด๐—ฟ๐—ฎ๐˜๐—ถ๐—ผ๐—ป:
โ†’ ๐๐š๐œ๐ค๐ž๐ง๐ ๐š๐ง๐ ๐…๐ซ๐จ๐ง๐ญ๐ž๐ง๐ ๐‚๐จ๐ฆ๐ฆ๐ฎ๐ง๐ข๐œ๐š๐ญ๐ข๐จ๐ง: Set up routes in Express.js that connect to your React frontend seamlessly.
โ†’ ๐€๐๐ˆ ๐„๐ง๐๐ฉ๐จ๐ข๐ง๐ญ๐ฌ: Build secure and reliable API endpoints for CRUD operations with MongoDB.
โ†’ ๐…๐ซ๐จ๐ง๐ญ๐ž๐ง๐ ๐ƒ๐š๐ญ๐š ๐…๐ž๐ญ๐œ๐ก๐ข๐ง๐ : Use Axios (or Fetch) to interact with your API from the React app in real-time.
โ†’ ๐€๐ฎ๐ญ๐ก๐ž๐ง๐ญ๐ข๐œ๐š๐ญ๐ข๐จ๐ง ๐š๐ง๐ ๐’๐ญ๐š๐ญ๐ž ๐Œ๐š๐ง๐š๐ ๐ž๐ฆ๐ž๐ง๐ญ: Secure user sessions and manage state across the full stack with JWT tokens and context.

  • Hereโ€™s a simplified flow:
  1. ๐Œ๐จ๐ง๐ ๐จ๐ƒ๐ stores the data.
  2. ๐„๐ฑ๐ฉ๐ซ๐ž๐ฌ๐ฌ.๐ฃ๐ฌ handles the API.
  3. ๐‘๐ž๐š๐œ๐ญ fetches the API data to render in the UI.
  4. ๐๐จ๐๐ž.๐ฃ๐ฌ ties it all together by running the backend logic.

This is the culmination of the journeyโ€”integrating all the pieces to create a dynamic, full-stack application. Itโ€™s where all the learning really clicks together.

2 Likes

๐ƒ๐š๐ฒ ๐Ÿ—๐Ÿ— of #100DaysOfCode

  • ๐‘ซ๐’†๐’‘๐’๐’๐’š๐’Š๐’๐’ˆ ๐’€๐’๐’–๐’“ ๐‘ด๐‘ฌ๐‘น๐‘ต ๐‘บ๐’•๐’‚๐’„๐’Œ ๐‘จ๐’‘๐’‘๐’๐’Š๐’„๐’‚๐’•๐’Š๐’๐’ -
    ๐˜›๐˜ข๐˜ฌ๐˜ช๐˜ฏ๐˜จ ๐˜ ๐˜ฐ๐˜ถ๐˜ณ ๐˜—๐˜ณ๐˜ฐ๐˜ซ๐˜ฆ๐˜ค๐˜ต ๐˜“๐˜ช๐˜ท๐˜ฆ โ€“ ๐˜‹๐˜ฆ๐˜ฑ๐˜ญ๐˜ฐ๐˜บ๐˜ฎ๐˜ฆ๐˜ฏ๐˜ต ๐˜š๐˜ต๐˜ณ๐˜ข๐˜ต๐˜ฆ๐˜จ๐˜ช๐˜ฆ๐˜ด ๐˜ง๐˜ฐ๐˜ณ ๐˜”๐˜Œ๐˜™๐˜•

With the entire MERN stack fully integrated, the next crucial step is deployment. Launching your app to the web involves configuring your frontend and backend to run in production, handling security, and ensuring performance optimization.

๐——๐—ฒ๐—ฝ๐—น๐—ผ๐˜†๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ถ๐—ฝ๐˜€:
โ†’ ๐‚๐ก๐จ๐จ๐ฌ๐ข๐ง๐  ๐ญ๐ก๐ž ๐‘๐ข๐ ๐ก๐ญ ๐๐ฅ๐š๐ญ๐Ÿ๐จ๐ซ๐ฆ: Services like Heroku, Vercel, or DigitalOcean can host your Node.js server, while platforms like Netlify or Firebase can handle the React frontend.
โ†’ ๐ƒ๐š๐ญ๐š๐›๐š๐ฌ๐ž ๐’๐ž๐ญ๐ฎ๐ฉ: Use MongoDB Atlas for a scalable, cloud-hosted database.
โ†’ ๐„๐ง๐ฏ๐ข๐ซ๐จ๐ง๐ฆ๐ž๐ง๐ญ ๐•๐š๐ซ๐ข๐š๐›๐ฅ๐ž๐ฌ: Keep your sensitive data (API keys, database URIs) secure by using environment variables on the hosting platform.
โ†’ ๐‚๐ˆ/๐‚๐ƒ ๐๐ข๐ฉ๐ž๐ฅ๐ข๐ง๐ž๐ฌ: Set up continuous integration and deployment pipelines to automate testing and deployment whenever you push code to your repository.
โ†’ ๐๐ซ๐จ๐๐ฎ๐œ๐ญ๐ข๐จ๐ง ๐Ž๐ฉ๐ญ๐ข๐ฆ๐ข๐ณ๐š๐ญ๐ข๐จ๐ง๐ฌ: Use build tools like npm run build for React to create optimized production bundles.

Deploying an app makes it accessible to the world, and itโ€™s an exciting moment to finally see your hard work in action. A good deployment strategy ensures your app is stable, secure, and scalable.

3 Likes

Congratulations @Ayman_Dandan! :slight_smile: Almost there! Excited for your next post!

What an incredible and impressive accomplishment! Please share your detailed experience of 100daysofcode with the community to inspire them! Thank you for being a part of it! :raised_hands:

1 Like