<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Mohd Suhel</title>
    <description>The latest articles on Forem by Mohd Suhel (@suheldevs).</description>
    <link>https://forem.com/suheldevs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2593584%2Fecc1a9c8-3d67-4099-b137-4c84f6bc332b.jpg</url>
      <title>Forem: Mohd Suhel</title>
      <link>https://forem.com/suheldevs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/suheldevs"/>
    <language>en</language>
    <item>
      <title>🚀 Deploy a MERN Full Stack Website for Free : full guide</title>
      <dc:creator>Mohd Suhel</dc:creator>
      <pubDate>Sun, 05 Jan 2025 07:30:38 +0000</pubDate>
      <link>https://forem.com/suheldevs/deploy-a-mern-full-stack-website-for-free-full-guide-94o</link>
      <guid>https://forem.com/suheldevs/deploy-a-mern-full-stack-website-for-free-full-guide-94o</guid>
      <description>&lt;p&gt;Deploying a full-stack MERN (MongoDB, Express.js, React, Node.js) project for free is easier than you think! With Render and Netlify, you can host both backend and frontend at no cost. This guide walks you through setting up the project, deploying it, and connecting the backend and frontend seamlessly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Setup: MERN Stack with Vite React
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Backend Setup
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Create a Backend Folder:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;mkdir backend&lt;br&gt;
cd backend&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initialize Node.js:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init -y
npm install express mongoose cors dotenv
npm install --save-dev nodemon
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Environment Variables (.env):
In the backend folder, create a .env file:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PORT=5000
MONGO_URI=your_mongodb_connection_string
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  2. Frontend Setup with Vite React
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a Vite React App:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir frontend
cd frontend
npm create vite@latest . --template react
npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Environment Variables (.env):
Create a .env file in the frontend folder:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VITE_BACKEND_URL=http://localhost:5000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Project Structure
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mern-project/  
│  
├── backend/  
│   ├── controllers/        # For handling business logic (e.g., userController.js)  
│   ├── models/             # MongoDB schemas (e.g., User.js)  
│   ├── routes/             # API routes (e.g., userRoutes.js)  
│   ├── .env                # Environment variables  
│   ├── index.js            # Entry point for the backend  
│   ├── package.json        # Backend dependencies  
│   └── README.md           # Backend-specific documentation  
│  
├── frontend/  
│   ├── public/             # Public files (e.g., index.html)  
│   ├── src/  
│   │   ├── components/     # Reusable components (e.g., Header.jsx, Footer.jsx)  
│   │   ├── pages/          # Pages (e.g., Home.jsx, Login.jsx)  
│   │   ├── styles/         # CSS/SCSS files  
│   │   ├── App.jsx         # Main app file  
│   │   ├── main.jsx        # ReactDOM render  
│   │   └── .env            # Frontend environment variables  
│   ├── vite.config.js      # Vite configuration  
│   ├── package.json        # Frontend dependencies  
│   └── README.md           # Frontend-specific documentation  
│  
└── README.md               # Main documentation for the entire project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🌐 Deploying the Backend on Render
&lt;/h2&gt;
&lt;h3&gt;
  
  
  1. Push Backend to GitHub:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/your-username/backend-repo.git
git push -u origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  2. Deploy on Render:
&lt;/h3&gt;

&lt;p&gt;`Log in to Render.&lt;/p&gt;

&lt;p&gt;Create a New Web Service.&lt;/p&gt;

&lt;p&gt;Connect your GitHub repository.`&lt;/p&gt;

&lt;p&gt;Set the following:&lt;/p&gt;

&lt;p&gt;Build Command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start Command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add environment variables (e.g., MONGO_URI) under Settings &amp;gt; Environment Variables.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Copy the Render URL: Once deployed, you’ll get a URL (e.g., &lt;a href="https://your-backend.onrender.com" rel="noopener noreferrer"&gt;https://your-backend.onrender.com&lt;/a&gt;).
&lt;/h3&gt;




&lt;h2&gt;
  
  
  🌐 Deploying the Frontend on Netlify
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Build the Frontend:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Push Frontend to GitHub:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/your-username/frontend-repo.git
git push -u origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Deploy on Netlify:
&lt;/h3&gt;

&lt;p&gt;Log in to Netlify.&lt;/p&gt;

&lt;p&gt;Create a New Site.&lt;/p&gt;

&lt;p&gt;Connect your GitHub repository.&lt;/p&gt;

&lt;p&gt;Set:&lt;/p&gt;

&lt;p&gt;Build Command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Publish Directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔗 Connecting Frontend and Backend
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Update the .env file in your frontend folder:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VITE_BACKEND_URL=https://your-backend.onrender.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Rebuild and redeploy the frontend on Netlify:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Testing the Application
&lt;/h2&gt;

&lt;p&gt;Open the Netlify URL for your frontend.&lt;/p&gt;

&lt;p&gt;Interact with your application and ensure everything works as expected.&lt;/p&gt;

&lt;p&gt;Debug any issues using Render logs or browser developer tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 Key Tips for a Smooth Deployment
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Monitor API Requests: Use tools like Postman to test backend endpoints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep Environment Variables Secure: Avoid hardcoding secrets in your code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optimize Build Performance: Use production settings for builds (e.g., NODE_ENV=production).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🙌 Conclusion
&lt;/h2&gt;

&lt;p&gt;With Render and Netlify, deploying a MERN stack project is quick, free, and efficient. Follow this guide to have your project live in no time.&lt;/p&gt;

&lt;p&gt;If you found this helpful, drop a comment or share it with your fellow developers!&lt;/p&gt;

&lt;p&gt;Have questions or feedback? Let me know!&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>react</category>
      <category>backend</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How to Optimize Your React Web App: 7 Essential Steps</title>
      <dc:creator>Mohd Suhel</dc:creator>
      <pubDate>Fri, 20 Dec 2024 03:34:42 +0000</pubDate>
      <link>https://forem.com/suheldevs/how-to-optimize-your-react-web-app-7-essential-steps-543a</link>
      <guid>https://forem.com/suheldevs/how-to-optimize-your-react-web-app-7-essential-steps-543a</guid>
      <description>&lt;p&gt;React is a powerful library for building dynamic user interfaces, but performance issues can arise as your application grows. In this guide, we’ll explore 7 essential steps to optimize your React web app and ensure it runs smoothly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/..." class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/..." alt="Uploading image" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Use React’s Built-in Performance Tools
&lt;/h2&gt;

&lt;p&gt;React offers several tools to help you identify and resolve performance bottlenecks:&lt;/p&gt;

&lt;p&gt;React Developer Tools:&lt;/p&gt;

&lt;p&gt;Use the Profiler tab to measure how components render and identify unnecessary renders.&lt;/p&gt;

&lt;p&gt;React Strict Mode:&lt;/p&gt;

&lt;p&gt;Enable strict mode to catch potential performance and coding issues during development.&lt;/p&gt;

&lt;p&gt;Tip: Wrap your app in React.StrictMode to surface warnings about inefficient patterns.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  &amp;lt;React.StrictMode&amp;gt;
    &amp;lt;App /&amp;gt;
  &amp;lt;/React.StrictMode&amp;gt;
);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Optimize Component Rendering
&lt;/h2&gt;

&lt;p&gt;Unnecessary re-renders can drastically slow down your app. You can optimize component rendering by:&lt;/p&gt;

&lt;p&gt;Using React.memo: Prevent functional components from re-rendering when their props don’t change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { memo } from 'react';

const MyComponent = ({ data }) =&amp;gt; {
  console.log('Rendering MyComponent');
  return &amp;lt;div&amp;gt;{data}&amp;lt;/div&amp;gt;;
};


export default memo(MyComponent);

Using useCallback and useMemo:

Use useCallback to memoize functions.

Use useMemo to memoize computationally expensive operations.



import React, { useCallback, useMemo } from 'react';

const App = ({ numbers }) =&amp;gt; {
  const calculateSum = useMemo(() =&amp;gt; numbers.reduce((a, b) =&amp;gt; a + b, 0), [numbers]);
  const handleClick = useCallback(() =&amp;gt; console.log('Clicked!'), []);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;h1&amp;gt;Sum: {calculateSum}&amp;lt;/h1&amp;gt;
      &amp;lt;button onClick={handleClick}&amp;gt;Click Me&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Code-Splitting with React.lazy
&lt;/h2&gt;

&lt;p&gt;Reduce your initial load time by splitting your app into smaller bundles using React.lazy and Suspense.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { Suspense } from 'react';

const HeavyComponent = React.lazy(() =&amp;gt; import('./HeavyComponent'));

const App = () =&amp;gt; {
  return (
    &amp;lt;Suspense fallback={&amp;lt;div&amp;gt;Loading...&amp;lt;/div&amp;gt;}&amp;gt;
      &amp;lt;HeavyComponent /&amp;gt;
    &amp;lt;/Suspense&amp;gt;
  );
};

export default App;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Avoid Inline Functions and Anonymous Functions
&lt;/h2&gt;

&lt;p&gt;Inline functions create new references every render, which can cause unnecessary re-renders. Instead, define functions outside the render logic or use useCallback.&lt;/p&gt;

&lt;p&gt;Bad Practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button onClick={() =&amp;gt; console.log('Clicked!')}&amp;gt;Click Me&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Good Practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const handleClick = () =&amp;gt; console.log('Clicked!');
&amp;lt;button onClick={handleClick}&amp;gt;Click Me&amp;lt;/button&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Reduce State and Props Drilling
&lt;/h2&gt;

&lt;p&gt;Avoid excessive state updates and unnecessary props drilling:&lt;/p&gt;

&lt;p&gt;Use Context API or state management libraries like Redux or Zustand for managing global state.&lt;/p&gt;

&lt;p&gt;Split components into smaller, focused components that manage their own state.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Optimize Images and Assets
&lt;/h2&gt;

&lt;p&gt;Large images and assets can slow down your app. Here’s how to optimize them:&lt;/p&gt;

&lt;p&gt;Use tools like ImageOptim or TinyPNG to compress images.&lt;/p&gt;

&lt;p&gt;Use responsive images with the srcset attribute or libraries like react-image.&lt;/p&gt;

&lt;p&gt;Lazy-load images using libraries like react-lazyload.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Minimize Dependencies
&lt;/h2&gt;

&lt;p&gt;Audit your package.json for unnecessary dependencies. Large bundles can slow down your app.&lt;/p&gt;

&lt;p&gt;Use tools like Bundlephobia to analyze the size of dependencies.&lt;/p&gt;

&lt;p&gt;Prefer lightweight alternatives or custom solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;p&gt;Use a Performance Monitoring Tool&lt;/p&gt;

&lt;p&gt;Leverage tools like Lighthouse, Sentry, or Datadog to monitor and debug performance issues in production.&lt;/p&gt;




&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Optimizing your React web app is a continuous process. Start by identifying performance bottlenecks with React tools and progressively apply these techniques. By following these steps, you’ll deliver a faster, more efficient user experience.&lt;/p&gt;

&lt;p&gt;If you found this guide helpful, feel free to share your optimization tips in the comments below!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
