<?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>DEV Community: Nikhil Singh Rajpoot</title>
    <description>The latest articles on DEV Community by Nikhil Singh Rajpoot (@nikhil_1x).</description>
    <link>https://dev.to/nikhil_1x</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%2F3465103%2Fd4292c99-416e-49b0-b1d9-6ed0b7a26b0f.png</url>
      <title>DEV Community: Nikhil Singh Rajpoot</title>
      <link>https://dev.to/nikhil_1x</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nikhil_1x"/>
    <language>en</language>
    <item>
      <title>“Stop Putting login.js in the Wrong Place — Here’s the Industry Standard”</title>
      <dc:creator>Nikhil Singh Rajpoot</dc:creator>
      <pubDate>Thu, 28 Aug 2025 12:21:29 +0000</pubDate>
      <link>https://dev.to/nikhil_1x/stop-putting-loginjs-in-the-wrong-place-heres-the-industry-standard-3pm3</link>
      <guid>https://dev.to/nikhil_1x/stop-putting-loginjs-in-the-wrong-place-heres-the-industry-standard-3pm3</guid>
      <description>&lt;p&gt;checkout my repo ----&amp;gt; &lt;a href="https://github.com/nikhilrajpoot21/InkFlow" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;br&gt;
As a backend-focused developer diving deeper into fullstack architecture, I recently explored a deceptively simple question: Where should I place my login.js file in a React + Node.js project?&lt;/p&gt;

&lt;p&gt;Turns out, the answer reveals a lot about how modern web apps are structured. Here's what I learned &lt;/p&gt;

&lt;p&gt;Frontend: UI Lives in pages/&lt;br&gt;
In React projects, the login screen is a visual component, not a route handler. So it belongs in:&lt;/p&gt;

&lt;p&gt;Code&lt;br&gt;
src/pages/Login.js&lt;/p&gt;

&lt;p&gt;This component handles:&lt;/p&gt;

&lt;p&gt;Rendering the login form&lt;/p&gt;

&lt;p&gt;Capturing user input&lt;/p&gt;

&lt;p&gt;Sending credentials to the backend via axios or fetch&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
jsx&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;form onSubmit={handleLogin}&amp;gt;
  &amp;lt;input type="email" ... /&amp;gt;
  &amp;lt;input type="password" ... /&amp;gt;
  &amp;lt;button type="submit"&amp;gt;Login&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Backend: Logic Lives in routes/ and controllers/&lt;br&gt;
The backend doesn’t render the login page — it processes login requests. So the logic goes here:&lt;/p&gt;

&lt;p&gt;Code&lt;br&gt;
/routes/auth.js   ← defines POST /login&lt;/p&gt;

&lt;p&gt;/controllers/authController.js   ← contains loginUser(req, res)&lt;br&gt;
Example:&lt;br&gt;
js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.loginUser = (req, res) =&amp;gt; {
  const { email, password } = req.body;  // Validate user, return token
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What About views/ in Backend? &lt;br&gt;
This was my biggest “aha” moment: In React-based projects, you don’t need backend views at all.&lt;/p&gt;

&lt;p&gt;Backend views (like EJS, Pug, Handlebars) are used in server-rendered apps. But in a React SPA:&lt;br&gt;
.The frontend renders all UI&lt;/p&gt;

&lt;p&gt;.The backend only serves JSON data&lt;/p&gt;

&lt;p&gt;.views/ folder is unnecessary&lt;/p&gt;

&lt;p&gt;Summary :-&lt;br&gt;
Role    Handled By  Folder Used&lt;br&gt;
UI Rendering    React   src/pages/&lt;br&gt;
Auth Logic  Express routes/, controllers/&lt;br&gt;
HTML Templates   Not used   views/ (skip it)&lt;/p&gt;

&lt;p&gt;Final Thoughts :-&lt;br&gt;
This small architectural decision — where to place login.js — taught me how clean separation between frontend and backend improves scalability, clarity, and maintainability. If you're building a fullstack app, understanding this split is essential.&lt;/p&gt;

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