<?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: Hiro Ventolero</title>
    <description>The latest articles on Forem by Hiro Ventolero (@augustin_ven).</description>
    <link>https://forem.com/augustin_ven</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%2F882842%2Fab9391b0-5a7c-448f-a25c-8d46333fbbb5.png</url>
      <title>Forem: Hiro Ventolero</title>
      <link>https://forem.com/augustin_ven</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/augustin_ven"/>
    <language>en</language>
    <item>
      <title>Optimizing React Performance: useMemo, useCallback, and Beyond</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 06 Oct 2025 19:36:44 +0000</pubDate>
      <link>https://forem.com/augustin_ven/optimizing-react-performance-usememo-usecallback-and-beyond-nnl</link>
      <guid>https://forem.com/augustin_ven/optimizing-react-performance-usememo-usecallback-and-beyond-nnl</guid>
      <description>&lt;p&gt;React is powerful — but if you’ve ever noticed your app getting sluggish as it grows, you’re not alone. Re-renders, expensive calculations, and unnecessary updates can quietly eat away at your app’s performance.&lt;/p&gt;

&lt;p&gt;In this post, we’ll explore how hooks like &lt;code&gt;useMemo&lt;/code&gt; and &lt;code&gt;useCallback&lt;/code&gt; can make your app faster and more efficient — and when &lt;strong&gt;not&lt;/strong&gt; to use them.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Understanding React Re-renders
&lt;/h2&gt;

&lt;p&gt;React’s rendering behavior is simple: whenever a component’s &lt;strong&gt;state or props&lt;/strong&gt; change, it re-renders.&lt;br&gt;
But sometimes, that re-render trickles down to &lt;strong&gt;child components&lt;/strong&gt; that didn’t need to update — causing performance issues.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Parent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;HeavyComponent&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;DisplayCount&lt;/span&gt; &lt;span class="na"&gt;count&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if only &lt;code&gt;count&lt;/code&gt; changes, &lt;code&gt;HeavyComponent&lt;/code&gt; might re-render — unnecessarily.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ useMemo: Cache Expensive Computations
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;useMemo&lt;/code&gt; helps you &lt;strong&gt;memoize&lt;/strong&gt; (remember) expensive calculations so they don’t re-run on every render.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;filteredList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;active&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;When to use it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Heavy loops or calculations&lt;/li&gt;
&lt;li&gt;Derived data that’s reused multiple times&lt;/li&gt;
&lt;li&gt;Expensive object or array creation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🚫 &lt;strong&gt;When NOT to use it:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For lightweight operations — it adds unnecessary overhead.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔁 useCallback: Stabilize Function References
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;useCallback&lt;/code&gt; is like &lt;code&gt;useMemo&lt;/code&gt; but for functions.&lt;br&gt;
It returns a memoized version of the callback that only changes when its dependencies change.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Clicked!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;💡 &lt;strong&gt;Why it matters:&lt;/strong&gt;&lt;br&gt;
When you pass functions as props to child components, React might re-render them unnecessarily.&lt;br&gt;
Using &lt;code&gt;useCallback&lt;/code&gt; ensures the function reference stays the same — reducing renders.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Beyond useMemo and useCallback
&lt;/h2&gt;

&lt;p&gt;Here are other ways to level up your React performance:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;React.memo()&lt;/strong&gt; – Wrap functional components to prevent re-rendering if props haven’t changed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Code Splitting&lt;/strong&gt; – Load only what’s needed using &lt;code&gt;React.lazy&lt;/code&gt; and &lt;code&gt;Suspense&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Virtualization&lt;/strong&gt; – Use libraries like &lt;code&gt;react-window&lt;/code&gt; for large lists.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid Anonymous Functions in JSX&lt;/strong&gt; – They create new references on every render.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Profile Your App&lt;/strong&gt; – Use the React DevTools Profiler to see where time is being spent.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 Putting It All Together
&lt;/h2&gt;

&lt;p&gt;Performance optimization is about balance — don’t overuse these hooks.&lt;br&gt;
Start by identifying real bottlenecks, and use memoization where it counts.&lt;/p&gt;

&lt;p&gt;Remember: clean, readable code beats micro-optimizations most of the time.&lt;/p&gt;




&lt;p&gt;💬 Have you used &lt;code&gt;useMemo&lt;/code&gt; or &lt;code&gt;useCallback&lt;/code&gt; in your projects?&lt;br&gt;
Share your favorite optimization tips in the comments!&lt;/p&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Improving Developer Experience with ESLint + Prettier</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 06 Oct 2025 19:23:59 +0000</pubDate>
      <link>https://forem.com/augustin_ven/improving-developer-experience-with-eslint-prettier-2ebm</link>
      <guid>https://forem.com/augustin_ven/improving-developer-experience-with-eslint-prettier-2ebm</guid>
      <description>&lt;p&gt;Ever opened your project and noticed inconsistent spacing, missing semicolons, or code that &lt;em&gt;just looks off&lt;/em&gt;?&lt;br&gt;
That’s where &lt;strong&gt;ESLint&lt;/strong&gt; and &lt;strong&gt;Prettier&lt;/strong&gt; come in — the dynamic duo that makes your code cleaner, more consistent, and easier to maintain.&lt;/p&gt;

&lt;p&gt;In this post, you’ll learn how to &lt;strong&gt;set up ESLint + Prettier&lt;/strong&gt; for your project and make your developer experience smoother than ever.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧠 What Are ESLint and Prettier?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ESLint&lt;/strong&gt; — a tool that &lt;em&gt;analyzes your JavaScript/TypeScript code&lt;/em&gt; and helps you find and fix problems (like unused variables, missing imports, or unsafe code).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prettier&lt;/strong&gt; — an &lt;em&gt;opinionated code formatter&lt;/em&gt; that ensures your code looks consistent across your team (same quotes, spacing, etc.).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Together, they:&lt;br&gt;
✅ Catch bugs early&lt;br&gt;
✅ Keep code style consistent&lt;br&gt;
✅ Save time spent on code reviews arguing about formatting&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚙️ Step 1: Install ESLint and Prettier
&lt;/h2&gt;

&lt;p&gt;If you’re using &lt;strong&gt;npm&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; eslint prettier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or with &lt;strong&gt;yarn&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add &lt;span class="nt"&gt;-D&lt;/span&gt; eslint prettier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧩 Step 2: Initialize ESLint
&lt;/h2&gt;

&lt;p&gt;Run this command to create a default ESLint configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx eslint &lt;span class="nt"&gt;--init&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll be asked a few questions — for example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How would you like to use ESLint? → “To check syntax, find problems, and enforce code style”&lt;/li&gt;
&lt;li&gt;What type of modules does your project use? (CommonJS / ES Modules)&lt;/li&gt;
&lt;li&gt;Does your project use TypeScript? (yes/no)&lt;/li&gt;
&lt;li&gt;Which framework are you using? (React, Vue, None)&lt;/li&gt;
&lt;li&gt;Where does your code run? (Browser / Node)&lt;/li&gt;
&lt;li&gt;Which format do you want your config file in? (JSON, YAML, or JavaScript)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will generate an &lt;code&gt;.eslintrc.json&lt;/code&gt; file in your project root.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎨 Step 3: Configure Prettier
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;.prettierrc&lt;/code&gt; file to define your formatting preferences:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"semi"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"singleQuote"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"tabWidth"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"trailingComma"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"es5"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"printWidth"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can adjust these based on your coding style or team conventions.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔧 Step 4: Integrate ESLint with Prettier
&lt;/h2&gt;

&lt;p&gt;By default, ESLint and Prettier can sometimes &lt;em&gt;conflict&lt;/em&gt; (e.g., ESLint wants double quotes, Prettier wants single).&lt;br&gt;
To fix that, install some helper plugins:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--save-dev&lt;/span&gt; eslint-config-prettier eslint-plugin-prettier
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then update your &lt;code&gt;.eslintrc.json&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"extends"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"eslint:recommended"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"plugin:react/recommended"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"plugin:prettier/recommended"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"plugins"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"prettier"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"prettier/prettier"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This setup tells ESLint to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Prettier for formatting rules&lt;/li&gt;
&lt;li&gt;Show Prettier issues directly in ESLint errors&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 Step 5: Add Scripts for Convenience
&lt;/h2&gt;

&lt;p&gt;In your &lt;code&gt;package.json&lt;/code&gt;, add shortcuts for linting and formatting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"lint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eslint ."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"lint:fix"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eslint . --fix"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"format"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"prettier --write ."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run lint
npm run lint:fix
npm run format
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧩 Step 6: Enable Auto-Fix on Save (VS Code)
&lt;/h2&gt;

&lt;p&gt;For the best experience, enable auto-formatting in VS Code:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;strong&gt;Settings (Ctrl + ,)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Search for &lt;code&gt;Format On Save&lt;/code&gt; and enable it&lt;/li&gt;
&lt;li&gt;Set the default formatter to &lt;strong&gt;Prettier - Code Formatter&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Optionally, create a workspace file &lt;code&gt;.vscode/settings.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"editor.formatOnSave"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"editor.defaultFormatter"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"esbenp.prettier-vscode"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"editor.codeActionsOnSave"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"source.fixAll.eslint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your code will auto-fix and format every time you save 😎&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Step 7: (Optional) Add Husky for Pre-Commit Linting
&lt;/h2&gt;

&lt;p&gt;Want to ensure bad code &lt;em&gt;never&lt;/em&gt; makes it into your repo?&lt;br&gt;
Add a Git hook that runs ESLint before every commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx husky-init &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then edit &lt;code&gt;.husky/pre-commit&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run lint:fix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, every commit automatically checks and formats your code before it’s saved in Git.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Setting up ESLint and Prettier might seem like extra work at first —&lt;br&gt;
but it’s a &lt;em&gt;massive&lt;/em&gt; time-saver in the long run.&lt;/p&gt;

&lt;p&gt;You’ll:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spend less time fixing formatting issues&lt;/li&gt;
&lt;li&gt;Catch bugs early&lt;/li&gt;
&lt;li&gt;Keep your project consistent across your whole team&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you try it, you’ll wonder how you ever coded without it ✨&lt;/p&gt;




</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>🔐 How to Set Up SSH Access for a Private GitLab Repository</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 06 Oct 2025 19:11:25 +0000</pubDate>
      <link>https://forem.com/augustin_ven/how-to-set-up-ssh-access-for-a-private-gitlab-repository-4n4l</link>
      <guid>https://forem.com/augustin_ven/how-to-set-up-ssh-access-for-a-private-gitlab-repository-4n4l</guid>
      <description>&lt;p&gt;If you’re working with &lt;strong&gt;private GitLab repositories&lt;/strong&gt;, you’ll often need to authenticate before cloning or pushing code.&lt;br&gt;
Instead of entering your username and password every time, you can securely connect using &lt;strong&gt;SSH keys&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This guide will walk you through how to &lt;strong&gt;generate SSH keys&lt;/strong&gt;, &lt;strong&gt;add them to GitLab&lt;/strong&gt;, and &lt;strong&gt;clone private repositories&lt;/strong&gt; using SSH.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧠 What is SSH?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SSH (Secure Shell)&lt;/strong&gt; allows secure communication between your computer and GitLab’s servers.&lt;/p&gt;

&lt;p&gt;Instead of using your password for every Git action, GitLab uses your &lt;strong&gt;SSH key pair&lt;/strong&gt; — a &lt;strong&gt;public key&lt;/strong&gt; (stored on GitLab) and a &lt;strong&gt;private key&lt;/strong&gt; (stored safely on your machine).&lt;/p&gt;


&lt;h2&gt;
  
  
  🧩 Step 1: Check for Existing SSH Keys
&lt;/h2&gt;

&lt;p&gt;Before generating a new SSH key, check if you already have one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-al&lt;/span&gt; ~/.ssh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see files like:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;you already have SSH keys.&lt;br&gt;
You can use them — or generate new ones for GitLab.&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚙️ Step 2: Generate a New SSH Key
&lt;/h2&gt;

&lt;p&gt;Generate a new SSH key using the &lt;strong&gt;Ed25519&lt;/strong&gt; algorithm (recommended):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; ed25519 &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"you@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your system doesn’t support Ed25519, use RSA:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-b&lt;/span&gt; 4096 &lt;span class="nt"&gt;-C&lt;/span&gt; &lt;span class="s2"&gt;"you@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When prompted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Enter file in which to save the key (/home/user/.ssh/id_ed25519):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press &lt;strong&gt;Enter&lt;/strong&gt; to accept the default location.&lt;/p&gt;

&lt;p&gt;You can also set a &lt;strong&gt;passphrase&lt;/strong&gt; for extra security (optional).&lt;/p&gt;




&lt;h2&gt;
  
  
  💾 Step 3: Start the SSH Agent and Add Your Key
&lt;/h2&gt;

&lt;h3&gt;
  
  
  macOS / Linux
&lt;/h3&gt;

&lt;p&gt;Run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
ssh-add ~/.ssh/id_ed25519
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Windows (Git Bash)
&lt;/h3&gt;

&lt;p&gt;If you’re using &lt;strong&gt;Git Bash&lt;/strong&gt;, do the same:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;ssh-agent &lt;span class="nt"&gt;-s&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
ssh-add ~/.ssh/id_ed25519
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  📋 Step 4: Copy Your Public SSH Key
&lt;/h2&gt;

&lt;p&gt;Now copy your &lt;strong&gt;public key&lt;/strong&gt; to your clipboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  macOS
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pbcopy &amp;lt; ~/.ssh/id_ed25519.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; ~/.ssh/id_ed25519.pub
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then manually copy the output.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows (Git Bash)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; ~/.ssh/id_ed25519.pub | clip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🌐 Step 5: Add Your SSH Key to GitLab
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to your &lt;strong&gt;GitLab account&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Navigate to &lt;strong&gt;User Settings → SSH Keys&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Paste your public key into the &lt;strong&gt;Key&lt;/strong&gt; field.&lt;/li&gt;
&lt;li&gt;Optionally, give it a &lt;strong&gt;title&lt;/strong&gt; (e.g., “My Laptop”).&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Add key&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;✅ Your SSH key is now linked to your GitLab account.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 Step 6: Test Your SSH Connection
&lt;/h2&gt;

&lt;p&gt;Run this command to confirm the connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-T&lt;/span&gt; git@gitlab.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see a message like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Welcome to GitLab, @yourusername!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means everything is working 🎉&lt;/p&gt;




&lt;h2&gt;
  
  
  💻 Step 7: Clone a Private Repository Using SSH
&lt;/h2&gt;

&lt;p&gt;Now you can clone private repositories securely.&lt;/p&gt;

&lt;p&gt;Find your SSH clone URL in GitLab:&lt;br&gt;
It looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git@gitlab.com:username/project-name.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone git@gitlab.com:username/project-name.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll no longer need to enter your GitLab credentials every time you push or pull code.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔧 Optional: Manage Multiple SSH Keys (If You Have Multiple Accounts)
&lt;/h2&gt;

&lt;p&gt;If you use different GitLab or GitHub accounts, create a custom SSH config file:&lt;/p&gt;

&lt;p&gt;Edit your config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/.ssh/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Host gitlab.com
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/id_ed25519
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and exit.&lt;br&gt;
Now Git will automatically use the right SSH key when connecting to GitLab.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Final Thoughts
&lt;/h2&gt;

&lt;p&gt;You’ve now configured &lt;strong&gt;SSH authentication for GitLab&lt;/strong&gt; — no more typing credentials every time you push or clone.&lt;/p&gt;

&lt;p&gt;This setup is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔒 More secure than HTTPS authentication&lt;/li&gt;
&lt;li&gt;⚡ Faster and easier for private repos&lt;/li&gt;
&lt;li&gt;💼 Ideal for teams and CI/CD pipelines&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now go ahead and clone your project the secure way! 🚀&lt;/p&gt;




</description>
      <category>git</category>
      <category>gitlab</category>
      <category>security</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>🚀 How to Install Node.js (or a Specific Version) on Windows, macOS, and Linux</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 06 Oct 2025 19:06:02 +0000</pubDate>
      <link>https://forem.com/augustin_ven/how-to-install-nodejs-or-a-specific-version-on-windows-macos-and-linux-18fe</link>
      <guid>https://forem.com/augustin_ven/how-to-install-nodejs-or-a-specific-version-on-windows-macos-and-linux-18fe</guid>
      <description>&lt;p&gt;If you’re diving into backend development or exploring frameworks like &lt;strong&gt;Express&lt;/strong&gt;, &lt;strong&gt;Next.js&lt;/strong&gt;, or &lt;strong&gt;NestJS&lt;/strong&gt;, installing Node.js is your first step.&lt;/p&gt;

&lt;p&gt;This guide covers how to install &lt;strong&gt;Node.js&lt;/strong&gt; (and a &lt;strong&gt;specific version&lt;/strong&gt;, if needed) on &lt;strong&gt;Windows&lt;/strong&gt;, &lt;strong&gt;macOS&lt;/strong&gt;, and &lt;strong&gt;Linux&lt;/strong&gt; — including &lt;strong&gt;npm&lt;/strong&gt;, &lt;strong&gt;nvm&lt;/strong&gt;, and version management tips.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 What is Node.js?
&lt;/h2&gt;

&lt;p&gt;Node.js is an open-source, cross-platform JavaScript runtime built on Chrome’s &lt;strong&gt;V8 engine&lt;/strong&gt;.&lt;br&gt;
It lets you run JavaScript outside the browser — perfect for creating servers, APIs, CLI tools, and full-stack applications.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧩 Step 1: Check if Node.js is Already Installed
&lt;/h2&gt;

&lt;p&gt;Open your terminal (or PowerShell on Windows) and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If both return version numbers, you already have Node.js installed.&lt;br&gt;
If not, let’s install it!&lt;/p&gt;


&lt;h2&gt;
  
  
  💻 Step 2: Install Node.js
&lt;/h2&gt;
&lt;h3&gt;
  
  
  🪟 For Windows Users
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Download the &lt;strong&gt;LTS (Long-Term Support)&lt;/strong&gt; version.&lt;/li&gt;
&lt;li&gt;Run the installer:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Accept the license&lt;/li&gt;
&lt;li&gt;Choose the destination folder&lt;/li&gt;
&lt;li&gt;✅ Check “Add to PATH”

&lt;ol&gt;
&lt;li&gt;Verify installation:
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   node &lt;span class="nt"&gt;-v&lt;/span&gt;
   npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🍎 For macOS Users
&lt;/h3&gt;

&lt;p&gt;You can install Node.js either with &lt;strong&gt;Homebrew&lt;/strong&gt; or the &lt;strong&gt;official installer&lt;/strong&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Option 1: Install via Homebrew (Recommended)
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To install a &lt;strong&gt;specific version&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;node@18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then link it to make it the default version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;link&lt;/span&gt; &lt;span class="nt"&gt;--overwrite&lt;/span&gt; node@18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Option 2: Install via Official Installer
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Visit &lt;a href="https://nodejs.org" rel="noopener noreferrer"&gt;https://nodejs.org&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Download the &lt;strong&gt;macOS Installer (LTS)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Run the setup and finish installation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🐧 For Linux Users (Ubuntu/Debian)
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Install Latest LTS
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; curl
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://deb.nodesource.com/setup_lts.x | &lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; bash -
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Install a Specific Version (e.g., Node 18)
&lt;/h4&gt;

&lt;p&gt;Replace &lt;code&gt;18.x&lt;/code&gt; with your desired version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://deb.nodesource.com/setup_18.x | &lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-E&lt;/span&gt; bash -
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; nodejs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify installation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
npm &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ⚙️ Step 3: Use nvm (Node Version Manager) for Flexibility
&lt;/h2&gt;

&lt;p&gt;If you manage multiple Node projects, &lt;strong&gt;nvm&lt;/strong&gt; (Node Version Manager) is the best way to switch between Node versions easily.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧰 Install nvm (macOS/Linux)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-o-&lt;/span&gt; https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 Install a Specific Version
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install &lt;/span&gt;18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To list all available versions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm ls-remote
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Switch between versions anytime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm use 18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set a default version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;alias &lt;/span&gt;default 18
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🪟 For Windows Users
&lt;/h3&gt;

&lt;p&gt;Install &lt;strong&gt;nvm for Windows&lt;/strong&gt; from:&lt;br&gt;
👉 &lt;a href="https://github.com/coreybutler/nvm-windows" rel="noopener noreferrer"&gt;https://github.com/coreybutler/nvm-windows&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once installed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nvm &lt;span class="nb"&gt;install &lt;/span&gt;18.17.1
nvm use 18.17.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧰 Step 4: Verify Installation and Run a Test App
&lt;/h2&gt;

&lt;p&gt;Create a folder and initialize a project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;my-node-app
&lt;span class="nb"&gt;cd &lt;/span&gt;my-node-app
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a simple &lt;code&gt;index.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Node.js is working!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If you see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node.js is working!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🎉 You’ve successfully installed Node.js!&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Optional: Update npm to the Latest Version
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; npm@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  ✅ Final Thoughts
&lt;/h2&gt;

&lt;p&gt;You now have Node.js installed — and even better, you can manage multiple versions effortlessly with &lt;code&gt;nvm&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This setup is essential if you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Work on multiple Node projects&lt;/li&gt;
&lt;li&gt;Use frameworks requiring specific Node versions&lt;/li&gt;
&lt;li&gt;Contribute to open-source repositories with version requirements&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>node</category>
      <category>programming</category>
    </item>
    <item>
      <title>Seamless Authentication in Next.js: A Step-by-Step NextAuth.js Tutorial (TypeScript)</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Tue, 20 May 2025 14:38:04 +0000</pubDate>
      <link>https://forem.com/augustin_ven/seamless-authentication-in-nextjs-a-step-by-step-nextauthjs-tutorial-typescript-1dil</link>
      <guid>https://forem.com/augustin_ven/seamless-authentication-in-nextjs-a-step-by-step-nextauthjs-tutorial-typescript-1dil</guid>
      <description>&lt;p&gt;Authentication is a cornerstone of almost every modern web application. For Next.js developers, NextAuth.js offers a robust, flexible, and easy-to-use solution for handling various authentication strategies. In this tutorial, we'll walk through setting up NextAuth.js in a Next.js project using TypeScript, focusing on a basic "credentials" provider (username/password) for demonstration purposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why NextAuth.js?&lt;/strong&gt;&lt;br&gt;
Flexible: Supports various authentication providers (OAuth, email, credentials, etc.).&lt;br&gt;
Secure: Handles sessions, JWTs, and secure cookies out of the box.&lt;br&gt;
Easy to Use: Simple API for common authentication flows.&lt;br&gt;
Built for Next.js: Integrates seamlessly with Next.js API routes and &lt;code&gt;getServerSideProps&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's dive in!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;br&gt;
Before we start, make sure you have:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Node.js installed&lt;/strong&gt;&lt;br&gt;
Familiarity with Next.js and React basics&lt;br&gt;
Basic understanding of TypeScript&lt;br&gt;
Step 1: Set Up Your Next.js Project&lt;br&gt;
First, let's create a new Next.js project with TypeScript. Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-next-app@latest nextauth-typescript-tutorial &lt;span class="nt"&gt;--typescript&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;nextauth-typescript-tutorial
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Install NextAuth.js&lt;/strong&gt;&lt;br&gt;
Now, install the next-auth package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;next-auth
&lt;span class="c"&gt;# or&lt;/span&gt;
yarn add next-auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Configure Environment Variables&lt;/strong&gt;&lt;br&gt;
NextAuth.js requires a secret for signing tokens and an optional database URL (if you plan to use a database adapter, which we won't cover in this basic example but is crucial for production).&lt;/p&gt;

&lt;p&gt;Create a .env.local file at the root of your project:&lt;/p&gt;

&lt;p&gt;Code snippet&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# .env.local&lt;/span&gt;
&lt;span class="nv"&gt;NEXTAUTH_SECRET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;YOUR_VERY_RANDOM_SECRET_STRING_HERE
&lt;span class="c"&gt;# You can generate a random string using: openssl rand -base64 32&lt;/span&gt;
&lt;span class="c"&gt;# For a quick dev secret, any sufficiently long random string will do.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important: Never share your NEXTAUTH_SECRET publicly. For production, ensure this is a strong, randomly generated string.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Create the NextAuth.js API Route&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;NextAuth.js operates via a dynamic API route. Create a new file at pages/api/auth/[...nextauth].ts.&lt;/p&gt;

&lt;p&gt;This file will contain all your NextAuth.js configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pages/api/auth/[...nextauth].ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;NextAuth&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;CredentialsProvider&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth/providers/credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nc"&gt;NextAuth&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nc"&gt;CredentialsProvider&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="c1"&gt;// The name to display on the sign in form (e.g., "Sign in with...")&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="c1"&gt;// `credentials` is used to generate a form on the sign in page.&lt;/span&gt;
      &lt;span class="c1"&gt;// You can specify which fields should be submitted, for example:&lt;/span&gt;
      &lt;span class="na"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Username&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jsmith&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Add logic here to look up the user from the credentials supplied&lt;/span&gt;
        &lt;span class="c1"&gt;// This is where you would connect to your database or authentication service.&lt;/span&gt;

        &lt;span class="c1"&gt;// For this example, we'll hardcode a user.&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;J Smith&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jsmith@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
          &lt;span class="c1"&gt;// Any object returned will be saved in `user` property of the JWT&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="c1"&gt;// If you return null then an error will be displayed advising the user to check their details.&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
          &lt;span class="c1"&gt;// You can also throw an error to trigger an error page or redirect.&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="c1"&gt;// ... add more providers here (e.g., GitHubProvider, GoogleProvider)&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="c1"&gt;// Optional: Add callbacks for more control over authentication flow&lt;/span&gt;
  &lt;span class="na"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// The `user` object is only available on the first login (sign-in)&lt;/span&gt;
      &lt;span class="c1"&gt;// or if you explicitly return it from `authorize`&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;session&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Send properties to the client, such as an `id` from a JWT.&lt;/span&gt;
      &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// Optional: Pages for custom login, error, etc.&lt;/span&gt;
  &lt;span class="na"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;signIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/auth/signin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Custom sign-in page&lt;/span&gt;
    &lt;span class="c1"&gt;// signOut: '/auth/signout',&lt;/span&gt;
    &lt;span class="c1"&gt;// error: '/auth/error', // Error code passed in query string as ?error=&lt;/span&gt;
    &lt;span class="c1"&gt;// verifyRequest: '/auth/verify-request', // Used for check email page&lt;/span&gt;
    &lt;span class="c1"&gt;// newUser: '/auth/new-user' // If set will redirect to this page after a new account is created&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// Debug mode for development&lt;/span&gt;
  &lt;span class="na"&gt;debug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODE_ENV&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;development&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation of pages/api/auth/[...nextauth].ts:&lt;/p&gt;

&lt;p&gt;NextAuth({...}): The main configuration object for NextAuth.js.&lt;br&gt;
providers: An array where you define all the authentication methods you want to support.&lt;br&gt;
CredentialsProvider: Allows users to sign in with a username and password (or any arbitrary credentials).&lt;br&gt;
name: The label shown on the sign-in button.&lt;br&gt;
credentials: Defines the input fields for your sign-in form.&lt;br&gt;
authorize: This is the core function where you validate the credentials. In a real application, you'd query your database here to find a matching user. If authentication is successful, return a User object; otherwise, return null.&lt;br&gt;
callbacks: Highly customizable functions that allow you to control what happens at different stages of the authentication flow.&lt;br&gt;
jwt({ token, user }): This callback is called whenever a JSON Web Token (JWT) is created or updated. You can add custom properties to the token here (e.g., user ID).&lt;br&gt;
session({ session, token }): This callback is called whenever a session is checked. You can expose properties from the token to the session object, which is then available on the client-side.&lt;br&gt;
pages: Allows you to define custom pages for various authentication states (sign-in, sign-out, error, etc.). This is crucial for a good user experience.&lt;br&gt;
debug: Set to true in development for helpful console logging.&lt;br&gt;
Step 5: Create a Custom Sign-In Page&lt;br&gt;
Since we specified /auth/signin as our custom sign-in page in the pages configuration, let's create it.&lt;/p&gt;

&lt;p&gt;Create pages/auth/signin.tsx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pages/auth/signin.tsx&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;signIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;getProviders&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;GetServerSidePropsContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;BuiltInProviderType&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth/providers/index&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ClientSafeProvider&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;LiteralUnion&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth/react/types&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;SignInPageProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;LiteralUnion&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BuiltInProviderType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ClientSafeProvider&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;SignIn&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;providers&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;SignInPageProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;textAlign&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;In&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;providers&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
        &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;provider&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;
                  &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                    &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;HTMLInputElement&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;HTMLInputElement&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

                    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;signIn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                      &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                      &lt;span class="na"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Prevent redirect for custom error handling&lt;/span&gt;
                      &lt;span class="na"&gt;callbackUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Redirect to home page on success&lt;/span&gt;
                    &lt;span class="p"&gt;});&lt;/span&gt;

                    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                      &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Basic error display&lt;/span&gt;
                    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                      &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Redirect manually on success&lt;/span&gt;
                    &lt;span class="p"&gt;}&lt;/span&gt;
                  &lt;span class="p"&gt;}}&lt;/span&gt;
                &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;required&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
                  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0.5rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;Password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;password&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;required&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
                  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0.5rem 1rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;In&lt;/span&gt;
                  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;              &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="p"&gt;);&lt;/span&gt;
          &lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="c1"&gt;// You can render other providers here if you add them (e.g., Google, GitHub)&lt;/span&gt;
          &lt;span class="c1"&gt;// return (&lt;/span&gt;
          &lt;span class="c1"&gt;//   &amp;lt;div key={provider.id} style={{ marginTop: '1rem' }}&amp;gt;&lt;/span&gt;
          &lt;span class="c1"&gt;//     &amp;lt;button onClick={() =&amp;gt; signIn(provider.id)}&amp;gt;&lt;/span&gt;
          &lt;span class="c1"&gt;//       Sign in with {provider.name}&lt;/span&gt;
          &lt;span class="c1"&gt;//     &amp;lt;/button&amp;gt;&lt;/span&gt;
          &lt;span class="c1"&gt;//   &amp;lt;/div&amp;gt;&lt;/span&gt;
          &lt;span class="c1"&gt;// );&lt;/span&gt;
        &lt;span class="p"&gt;})}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getServerSideProps&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;GetServerSidePropsContext&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;providers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getProviders&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;providers&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation of pages/auth/signin.tsx:&lt;/p&gt;

&lt;p&gt;getProviders(): A NextAuth.js utility function that fetches all configured providers from your API route.&lt;br&gt;
signIn(): The core function to initiate the sign-in process. When using the credentials provider, you pass the provider ID ('credentials') and an object containing the credentials.&lt;br&gt;
redirect: false is important for handling errors on the client-side without a full page reload.&lt;br&gt;
callbackUrl specifies where to redirect after successful authentication.&lt;br&gt;
getServerSideProps: Used to fetch the available providers on the server-side before the page renders, ensuring they are available to the client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Wrap Your Application with SessionProvider&lt;/strong&gt;&lt;br&gt;
For NextAuth.js to work correctly across your application, you need to wrap your _app.tsx component with SessionProvider. This provides the session context to all components.&lt;/p&gt;

&lt;p&gt;Modify pages/_app.tsx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pages/_app.tsx&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;AppProps&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/app&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;SessionProvider&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Session&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Import Session type&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;CustomAppProps&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;AppProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;pageProps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AppProps&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pageProps&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Explicitly define session in pageProps&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;pageProps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;pageProps&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;CustomAppProps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;SessionProvider&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;{...&lt;/span&gt;&lt;span class="nx"&gt;pageProps&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/SessionProvider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation of pages/_app.tsx:&lt;/p&gt;

&lt;p&gt;SessionProvider: A React Context Provider that makes the session data available to all child components.&lt;br&gt;
session={session}: The session object is passed from pageProps, which is populated by NextAuth.js when a user is authenticated.&lt;br&gt;
Step 7: Implement Authentication in a Page&lt;br&gt;
Now, let's create a simple page to demonstrate how to check authentication status and sign in/out.&lt;/p&gt;

&lt;p&gt;Modify pages/index.tsx:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// pages/index.tsx&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useSession&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;signIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;signOut&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next-auth/react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Home&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loading&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;textAlign&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;center&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Welcome&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;NextAuth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt; &lt;span class="nx"&gt;Tutorial&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Signed&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;User&lt;/span&gt; &lt;span class="nx"&gt;ID&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;signOut&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0.5rem 1rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;Out&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;You&lt;/span&gt; &lt;span class="nx"&gt;are&lt;/span&gt; &lt;span class="nx"&gt;not&lt;/span&gt; &lt;span class="nx"&gt;signed&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/auth/signin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;passHref&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0.5rem 1rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;In&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="p"&gt;)}&lt;/span&gt;

      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;marginTop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2rem&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Protected&lt;/span&gt; &lt;span class="nc"&gt;Content &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Example&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;content&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;only&lt;/span&gt; &lt;span class="nx"&gt;visible&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;authenticated&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Please&lt;/span&gt; &lt;span class="nx"&gt;sign&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;view&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="p"&gt;)}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation of pages/index.tsx:&lt;/p&gt;

&lt;p&gt;useSession(): A React Hook provided by NextAuth.js that gives you access to the session data (session) and the loading status (status).&lt;br&gt;
session object: Contains information about the authenticated user (e.g., user.name, user.email). We also added user.id through our callbacks in [...nextauth].ts.&lt;br&gt;
signIn() / signOut(): Functions to programmatically sign in or out a user. When used without arguments, signIn() will redirect to the signIn page defined in your NextAuth.js config.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: Run Your Application&lt;/strong&gt;&lt;br&gt;
Start your Next.js development server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;span class="c"&gt;# or&lt;/span&gt;
yarn dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, open your browser and navigate to &lt;code&gt;http://localhost:3000&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You should see the "You are not signed in" message.&lt;br&gt;
Click the "Sign In" button, which will redirect you to &lt;a href="http://localhost:3000/auth/signin" rel="noopener noreferrer"&gt;http://localhost:3000/auth/signin&lt;/a&gt;.&lt;br&gt;
Enter username: user and password: password and click "Sign In".&lt;br&gt;
You should be redirected back to the home page, now showing "Signed in as J Smith" (or your hardcoded user's name/email).&lt;br&gt;
Try signing out and signing in again.&lt;br&gt;
Conclusion&lt;br&gt;
Congratulations! You've successfully implemented a basic authentication system in your Next.js application using NextAuth.js with a credentials provider.&lt;/p&gt;

&lt;p&gt;This tutorial provides a solid foundation. From here, you can explore:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding more providers:&lt;/strong&gt; Integrate with Google, GitHub, Facebook, etc., by adding their respective providers to pages/api/auth/[...nextauth].ts.&lt;br&gt;
&lt;strong&gt;Database Adapters:&lt;/strong&gt; For production applications, you'll need a database to persist user data and sessions. NextAuth.js offers various adapters (Prisma, Mongoose, TypeORM, etc.).&lt;br&gt;
&lt;strong&gt;Protecting API Routes:&lt;/strong&gt; Use getServerSession (or getToken if not using session) in your API routes to protect them.&lt;br&gt;
Customizing UI: Style your sign-in and other authentication pages to match your brand.&lt;br&gt;
&lt;strong&gt;Role-Based Access Control (RBAC):&lt;/strong&gt; Extend the session and token to include user roles for fine-grained access control.&lt;br&gt;
NextAuth.js streamlines the complexities of authentication, allowing you to focus on building amazing applications. Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How Docker Revolutionized the Tech Industry</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Fri, 29 Nov 2024 08:28:35 +0000</pubDate>
      <link>https://forem.com/augustin_ven/how-docker-revolutionized-the-tech-industry-77i</link>
      <guid>https://forem.com/augustin_ven/how-docker-revolutionized-the-tech-industry-77i</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fesih3wrde84ssbuyc4sa.jpg" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fesih3wrde84ssbuyc4sa.jpg" alt=" " width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In recent years, Docker has emerged as a groundbreaking tool in the world of software development and deployment. It's hard to overstate the impact Docker has had on the tech industry, enabling organizations to build, ship, and run applications in a more efficient and scalable manner. In this blog post, we’ll explore what Docker is, how it works, and why it has become such a revolutionary force in the tech landscape.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Docker?
&lt;/h2&gt;

&lt;p&gt;Docker is an open-source platform that allows developers to automate the deployment of applications inside lightweight, portable containers. Containers can hold everything an application needs to run — from code and runtime to system tools and libraries — ensuring that the application runs consistently in any environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Key Components of Docker:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Docker Images&lt;/strong&gt;: These are read-only templates used to create containers. They include everything required to run an application, including code, libraries, and dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Containers&lt;/strong&gt;: These are the runnable instances of Docker images, isolated from one another and the host system. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker Hub&lt;/strong&gt;: This is a cloud-based repository where developers can share, distribute, and manage Docker images.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How Docker Works
&lt;/h2&gt;

&lt;p&gt;At its core, Docker takes advantage of containerization technology, which allows applications to run in isolated user spaces. This isolation ensures that the applications do not interfere with one another, allowing for cleaner development workflows and a reduction in conflicts.&lt;/p&gt;

&lt;p&gt;When a developer wants to run an application, instead of installing the required software dependencies and configuration on their local machine or a server, they simply pull the relevant Docker image and run it as a container. This means that development environments can be spun up quickly, and applications can be tested and deployed with ease.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Revolution in Software Development
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Simplified Development and Deployment
&lt;/h3&gt;

&lt;p&gt;Docker simplifies the development lifecycle by allowing developers to create a consistent environment across all stages — from development and testing to production. This eliminates the “it works on my machine” syndrome, drastically reducing bugs and deployment errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Increased Scalability
&lt;/h3&gt;

&lt;p&gt;Docker containers can be easily scaled up or down to meet demand. This elasticity is essential for applications that experience variable workloads. Developers can spin up new containers in seconds, ensuring that their applications can handle increased traffic without performance degradation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Resource Efficiency
&lt;/h3&gt;

&lt;p&gt;Containers are lightweight compared to traditional virtual machines (VMs) because they share the host OS kernel rather than requiring their own operating system. This leads to reduced resource consumption and faster startup times, which is particularly beneficial in cloud environments where costs are often tied to resource usage.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Microservices Architecture
&lt;/h3&gt;

&lt;p&gt;Docker's containerization lends itself well to microservices architecture, allowing developers to build applications as a collection of loosely coupled services. This approach not only enhances flexibility and scalability but also enables teams to work on different services independently, accelerating development time.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Enhanced CI/CD Pipelines
&lt;/h3&gt;

&lt;p&gt;With Docker, Continuous Integration and Continuous Deployment (CI/CD) pipelines can be made more robust. Automated testing and deployment processes can be streamlined using Docker containers, leading to faster cycles and more reliable releases.&lt;/p&gt;

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

&lt;p&gt;Docker has fundamentally changed the way software is developed, tested, and deployed. Its focus on containerization has led to greater efficiency, improved collaboration among downstream teams, and has enabled organizations to deploy applications more quickly and reliably than ever before.&lt;/p&gt;

&lt;p&gt;As the tech industry continues to evolve, tools like Docker will play a crucial role in shaping the future of software development. By enabling developers to focus on writing code without the headaches of environment discrepancies, Docker truly bridges the gap between development and operations, embodying the essence of modern DevOps practices.&lt;/p&gt;

&lt;p&gt;For developers and organizations not yet leveraging Docker, now is the time to embrace this revolutionary tool and unlock the full potential of your applications and infrastructure. The future is containerized, and it’s an exciting space to be in!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ngrok on Ubuntu under Windows Subsystem for Linux (WSL)</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Fri, 29 Nov 2024 02:13:57 +0000</pubDate>
      <link>https://forem.com/augustin_ven/ngrok-on-ubuntu-under-windows-subsystem-for-linux-wsl-3cd3</link>
      <guid>https://forem.com/augustin_ven/ngrok-on-ubuntu-under-windows-subsystem-for-linux-wsl-3cd3</guid>
      <description>&lt;h1&gt;
  
  
  Ngrok Installation Guide for Ubuntu on WSL
&lt;/h1&gt;

&lt;p&gt;This guide will help you install Ngrok on your Ubuntu environment running under Windows Subsystem for Linux (WSL). Ngrok is a tool that allows you to expose your local server to the internet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Ensure that you have WSL installed on your Windows machine with Ubuntu as your chosen distribution. You should also have an active internet connection to download Ngrok.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Open Your WSL Terminal
&lt;/h2&gt;

&lt;p&gt;Launch your WSL terminal (Ubuntu) from the Windows start menu.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Update Your Package List
&lt;/h2&gt;

&lt;p&gt;Before installing any packages, it's a good idea to update the package list. Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Remove Any Previous Ngrok Files
&lt;/h2&gt;

&lt;p&gt;To avoid confusion, remove any previous downloads of Ngrok:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;rm &lt;/span&gt;ngrok.zip ngrok-stable-linux-amd64.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Download Ngrok
&lt;/h2&gt;

&lt;p&gt;You can download the latest version of Ngrok directly. Visit the Ngrok &lt;a href="https://ngrok.com/download" rel="noopener noreferrer"&gt;download page&lt;/a&gt; to get the most current URL, or use the command below to download it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget https://bin.equinox.io/c/111111/ngrok-stable-linux-amd64.zip &lt;span class="nt"&gt;-O&lt;/span&gt; ngrok.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Replace &lt;code&gt;111111&lt;/code&gt; with the actual key you find on the Ngrok download page if necessary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Alternate Download Method
&lt;/h3&gt;

&lt;p&gt;If the above command fails, you can use the following command, which extracts the download link directly from the Ngrok website:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://ngrok.com/download | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="s1"&gt;'https://[^"]*ngrok-stable-linux-amd64.zip'&lt;/span&gt; | xargs wget &lt;span class="nt"&gt;-O&lt;/span&gt; ngrok.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Unzip the Downloaded File
&lt;/h2&gt;

&lt;p&gt;Once the download is complete, extract the contents of the ZIP file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;unzip ngrok.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you encounter an error indicating that the file is not a valid zip file, ensure that the download was completed successfully. You can check the file type with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;file ngrok.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It should report that it is a "Zip archive data".&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Move Ngrok to Your Local Bin Directory
&lt;/h2&gt;

&lt;p&gt;After successfully unzipping, move the Ngrok binary to your local bin directory to make it executable from anywhere:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mv &lt;/span&gt;ngrok /usr/local/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 7: Authenticate Your Ngrok Account
&lt;/h2&gt;

&lt;p&gt;To use Ngrok, you will need to authenticate with your Ngrok token. Sign up at &lt;a href="https://ngrok.com" rel="noopener noreferrer"&gt;ngrok.com&lt;/a&gt; if you don’t already have an account. After logging in, copy your authentication token and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ngrok authtoken &amp;lt;your_auth_token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;&amp;lt;your_auth_token&amp;gt;&lt;/code&gt; with the actual token you received from your Ngrok dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 8: Start Using Ngrok
&lt;/h2&gt;

&lt;p&gt;You can now start using Ngrok to expose your local server to the internet. For instance, if you have a Django application running on port 8000, you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ngrok http 8000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will provide you with a public URL that tunnels to your local server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Information
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Once Ngrok is running, you can access the web interface at &lt;code&gt;http://127.0.0.1:4040&lt;/code&gt; to monitor requests and inspect traffic.&lt;/li&gt;
&lt;li&gt;Ensure that your local server (e.g., Django or Flask) is running before starting Ngrok.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;If you encounter issues during installation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check your internet connection to ensure it is stable.&lt;/li&gt;
&lt;li&gt;Verify that you have enough disk space on your system.&lt;/li&gt;
&lt;li&gt;If downloads repeatedly fail, consider downloading the Ngrok executable from another machine and transferring it to your WSL environment.&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>tunneling</category>
      <category>ngrok</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Writing Clean Python Code: Embracing the Zen of Python 🐍✨</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 25 Nov 2024 06:31:08 +0000</pubDate>
      <link>https://forem.com/augustin_ven/writing-clean-python-code-embracing-the-zen-of-python-39cc</link>
      <guid>https://forem.com/augustin_ven/writing-clean-python-code-embracing-the-zen-of-python-39cc</guid>
      <description>&lt;h2&gt;
  
  
  Writing Clean Python Code: Embracing the Zen of Python 🐍✨
&lt;/h2&gt;

&lt;p&gt;Writing clean, readable, and maintainable code is a hallmark of a great programmer. Python, with its simplicity and elegance, encourages developers to write beautiful code through the guiding principles of &lt;strong&gt;The Zen of Python&lt;/strong&gt; (PEP 20). Let’s break down these principles and see how to apply them in your coding journey.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;1. Beautiful is better than ugly.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Write code that is pleasing to the eye. Use consistent naming conventions, indentation, and spacing. Avoid cryptic variable names and overly complex one-liners.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Ugly code
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;fx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;span class="c1"&gt;# Beautiful code
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;add_numbers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;2. Explicit is better than implicit.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Make your code’s intent clear. Avoid clever hacks that only &lt;em&gt;you&lt;/em&gt; understand—write code that others (or future you) can easily grasp.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Implicit and unclear
&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Explicit and clear
&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;odd_numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;3. Simple is better than complex.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Strive for simplicity without sacrificing clarity. Complex solutions might feel clever, but they often create maintenance headaches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Complex solution
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Simple solution
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;4. Readability counts.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Readable code is a gift to anyone who works on your project. Use comments, docstrings, and meaningful names to make your code self-explanatory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Not readable
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="mi"&gt;365&lt;/span&gt;

&lt;span class="c1"&gt;# Readable
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;convert_years_to_days&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;years&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Converts years into days.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;years&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;365&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;5. Errors should never pass silently.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Handle exceptions explicitly so bugs don’t go unnoticed. Use &lt;code&gt;try&lt;/code&gt; and &lt;code&gt;except&lt;/code&gt; blocks wisely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Silent failure (not recommended)
&lt;/span&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="c1"&gt;# Explicit error handling
&lt;/span&gt;&lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;ZeroDivisionError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Cannot divide by zero!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;6. There should be one—and preferably only one—obvious way to do it.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Stick to Python’s idiomatic way of solving problems. Avoid reinventing the wheel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Non-idiomatic way to calculate the length of a list
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;list_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;

&lt;span class="c1"&gt;# Idiomatic way
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;list_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;7. If the implementation is hard to explain, it’s a bad idea.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If you can’t explain your code to a colleague in simple terms, it’s a sign you need to refactor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Hard to explain
&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nf"&gt;chr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;ord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# Easy to explain
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;shift_letters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;shift&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;Shifts each letter by a given number of positions.&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nf"&gt;chr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;ord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;shift_letters&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;hello&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;8. Refactor often.&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Code evolves over time. Regularly revisit your code to simplify, optimize, or align it better with Pythonic principles.&lt;/p&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;The Zen of Python is more than just a set of abstract ideas—it’s a practical guide to writing clean, maintainable code. By embracing its principles, you’ll create programs that are not only functional but also a joy to read and work on.  &lt;/p&gt;

&lt;p&gt;Keep coding clean, stay Pythonic, and remember: &lt;em&gt;Simple is better than complex.&lt;/em&gt; 🐍✨&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>cleancoding</category>
      <category>code</category>
    </item>
    <item>
      <title>Enhancing Large Language Models with Vectorized Databases: Powering AI at Scale</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 30 Oct 2023 14:08:06 +0000</pubDate>
      <link>https://forem.com/augustin_ven/enhancing-large-language-models-with-vectorized-databases-powering-ai-at-scale-3bki</link>
      <guid>https://forem.com/augustin_ven/enhancing-large-language-models-with-vectorized-databases-powering-ai-at-scale-3bki</guid>
      <description>&lt;h2&gt;
  
  
  Vectorized Databases: Powering AI at Scale
&lt;/h2&gt;

&lt;p&gt;In the ever-evolving world of artificial intelligence, Large Language Models (LLMs) like GPT-3 have proven to be revolutionary. These models have redefined natural language processing, enabling applications that range from chatbots and language translation to content generation. Yet, as these models grow in complexity and capability, the underlying infrastructure needs to keep pace. One solution that's gaining prominence is the use of vectorized databases, a game-changer for powering LLM AI models at scale.&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbwqg75k0674c82n7bxc.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsbwqg75k0674c82n7bxc.png" alt="How Vectorized Database Works" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://redis.com/solutions/use-cases/vector-database/" rel="noopener noreferrer"&gt;Image source&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Understanding Large Language Models
&lt;/h3&gt;

&lt;p&gt;Large Language Models, such as GPT-3, have set new standards for natural language understanding and generation. They are trained on massive datasets, learning patterns, context, and semantics from an extensive array of texts. These models are capable of responding to text inputs with coherent, context-aware, and contextually relevant outputs.&lt;br&gt;
However, the power of LLMs comes with substantial computational demands. These models require extensive memory and computational resources for both training and deployment. With the growth of AI applications, maintaining performance and efficiency has become a significant challenge.&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fablo1ub4kggkrg09wt3p.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fablo1ub4kggkrg09wt3p.png" alt="Large language models" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://webz.io/blog/machine-learning/large-language-models-what-your-data-must-include/" rel="noopener noreferrer"&gt;Image source&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The Role of Vectorized Databases
&lt;/h3&gt;

&lt;p&gt;Vectorized databases are designed to efficiently handle large datasets by leveraging vectorization techniques. In essence, they store and manage data in a way that's highly optimized for numerical and vector operations, making them particularly well-suited for AI and machine learning workloads.&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmtnq8fv9q46orlt2z0t.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmtnq8fv9q46orlt2z0t.png" alt="Vector Database" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Here's how vectorized databases can enhance LLMs:
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Efficient Data Retrieval:
&lt;/h4&gt;

&lt;p&gt;LLMs need quick access to vast amounts of training data. Vectorized databases excel at rapidly fetching and processing this data, reducing latency in model training and inference.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.  Optimized Vector Operations:
&lt;/h4&gt;

&lt;p&gt;LLMs rely on vectorized operations for tasks like word embeddings and similarity calculations. Vectorized databases can perform these operations efficiently, enhancing model performance.&lt;/p&gt;

&lt;h4&gt;
  
  
  3.  Scalability:
&lt;/h4&gt;

&lt;p&gt;As AI applications grow, the ability to scale becomes critical. Vectorized databases are designed with scalability in mind, accommodating the expanding data requirements of LLMs.&lt;/p&gt;

&lt;h4&gt;
  
  
  4.  Real-time Inference:
&lt;/h4&gt;

&lt;p&gt;In production, LLMs often require real-time responses. Vectorized databases can assist in quickly retrieving and serving data to ensure low-latency responses.&lt;/p&gt;

&lt;h4&gt;
  
  
  5.  Ease of Management:
&lt;/h4&gt;

&lt;p&gt;The management of extensive datasets is simplified with vectorized databases, as they streamline data storage and retrieval processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Cases and Applications
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzsq86j4tghrjsdympw5.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdzsq86j4tghrjsdympw5.png" alt="Use cases of Vectorized Database" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.linkedin.com/pulse/3-ways-vector-databases-take-your-llm-use-cases-next-level-mishra/" rel="noopener noreferrer"&gt;Image Source&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Vectorized databases offer a wide range of applications for LLMs:
&lt;/h4&gt;

&lt;h4&gt;
  
  
  1. Content Generation:
&lt;/h4&gt;

&lt;p&gt;LLMs can create high-quality content in real-time, whether it's articles, code snippets, or personalized responses in chatbots.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. Recommendation Systems:
&lt;/h4&gt;

&lt;p&gt;Vectorized databases enhance the efficiency of recommendation algorithms by handling user data and content embeddings.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Language Translation: LLMs are integral to language translation services, where vectorized databases help manage multilingual data efficiently.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  4. Sentiment Analysis: Analyzing vast amounts of text data for sentiment and emotion analysis becomes more effective with vectorized databases.
&lt;/h4&gt;

&lt;h4&gt;
  
  
  5. Data Search and Retrieval: LLMs can be used to develop advanced data search and retrieval systems, where vectorized databases optimize the process.
&lt;/h4&gt;

&lt;h2&gt;
  
  
  Challenges and Considerations
&lt;/h2&gt;

&lt;p&gt;While vectorized databases offer significant advantages, they also present challenges. Proper data modeling and integration are necessary, and organizations should evaluate factors like data size, query complexity, and scalability when adopting vectorized databases for LLMs.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Conclusion
&lt;/h2&gt;

&lt;p&gt;As Large Language Models continue to advance, the need for efficient data management and retrieval solutions becomes more pronounced. Vectorized databases are poised to play a crucial role in empowering LLMs for tasks that require immense language understanding and generation. Their ability to optimize data storage and retrieval, perform vectorized operations, and scale with growing data requirements makes them a valuable addition to the AI ecosystem. With the integration of vectorized databases, LLMs can reach new heights of performance and application across various domains, revolutionizing the way we interact with AI-powered systems.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>vectordatabase</category>
      <category>database</category>
    </item>
    <item>
      <title>How we Protect Our Data at Bespoke Enterprise Solutions Inc.</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 30 Oct 2023 09:34:46 +0000</pubDate>
      <link>https://forem.com/augustin_ven/how-we-protect-our-data-at-bespoke-enterprise-solutions-inc-5hkk</link>
      <guid>https://forem.com/augustin_ven/how-we-protect-our-data-at-bespoke-enterprise-solutions-inc-5hkk</guid>
      <description>&lt;h2&gt;
  
  
  Detecting Data Theft with Wazuh
&lt;/h2&gt;

&lt;p&gt;Data theft involves the unauthorized acquisition of data residing within business databases, endpoints, and servers. This pilfered information encompasses items such as credentials, credit card details, personally identifiable information, medical records, software code, and proprietary technologies. Data theft is a peril that can manifest both within and beyond an organization's boundaries. Malignant actors may purloin data from either organizations or individuals with the intention of selling it to other malicious parties. Data theft poses a significant threat to numerous entities since it can lead to issues like identity theft, harm to reputation, and financial setbacks.&lt;/p&gt;

&lt;h3&gt;
  
  
  How Bespoke Detect Data Theft: Utilizing Wazuh for Data Theft Detection at Bespoke Enterprise Solutions Inc.
&lt;/h3&gt;

&lt;p&gt;Wazuh, an enterprise-ready security solution, plays a pivotal role in enhancing security measures at Bespoke Enterprise Solutions Inc. Its open-source nature, combined with an array of features, enables our organization to detect and respond to data theft effectively.&lt;/p&gt;

&lt;p&gt;Wazuh serves as a comprehensive tool that unifies SIEM (Security Information and Event Management) and XDR (Extended Detection and Response) protection, covering various workloads within our infrastructure.&lt;/p&gt;

&lt;p&gt;One of its core strengths lies in providing a centralized dashboard for threat detection and security monitoring. This dashboard seamlessly spans virtualized, on-premises, cloud-based, and containerized environments, allowing us to maintain a holistic view of our security landscape.&lt;/p&gt;

&lt;p&gt;Wazuh extends several capabilities that empower our organization to take proactive steps in averting, identifying, and addressing security threats. Below, we shed light on key features and functionalities of Wazuh that are instrumental in safeguarding your data against theft.&lt;/p&gt;

&lt;h3&gt;
  
  
  File Integrity Monitoring (FIM) and Data Theft Detection
&lt;/h3&gt;

&lt;p&gt;Within the security framework of Wazuh, the File Integrity Monitoring (FIM) module plays a critical role in safeguarding data integrity. This module continually observes the files and directories on an endpoint, promptly raising alerts when it detects file creation, modification, or deletion activities.&lt;/p&gt;

&lt;p&gt;Wazuh's FIM module goes a step further by preserving cryptographic checksums and other file attributes, as well as monitoring changes to Windows registry keys. This meticulous record-keeping allows us to identify any alterations to these values with precision. Monitoring takes place at regular intervals or even in near real-time, ensuring swift response to any unauthorized changes.&lt;/p&gt;

&lt;p&gt;Malicious actors often employ malware to pilfer data from endpoints, with these harmful programs creating or downloading malicious files onto the compromised systems. Wazuh's FIM module excels in detecting these nefarious activities when such files are created or downloaded on the affected endpoints.&lt;/p&gt;

&lt;p&gt;As an example, the Wazuh FIM module successfully identifies instances of files being generated and downloaded by the STRRAT malware, underscoring its efficacy in data theft prevention. You can observe this detection in Figure below.&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9tdivpcths8m7p64q62.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb9tdivpcths8m7p64q62.png" alt="File Integrity Monitoring and Data Theft Detection" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Identifying Vulnerabilities with Wazuh
&lt;/h3&gt;

&lt;p&gt;The core function of vulnerability detection is to pinpoint security frailties within both the operating system and the applications residing on the monitored endpoints. Wazuh employs its dedicated Vulnerability Detector module to carry out this crucial task.&lt;/p&gt;

&lt;p&gt;To enable this process, Wazuh creates a comprehensive vulnerability database, drawing information from widely accessible Common Vulnerabilities and Exposures (CVE) repositories. This database acts as a central resource for cross-referencing with the inventory data of applications collected from the monitored endpoints. Through this meticulous comparison, the Vulnerability Detector module can successfully flag any software that exhibits vulnerabilities.&lt;/p&gt;

&lt;p&gt;By doing so, the Wazuh Vulnerability Detector module unveils unpatched vulnerabilities on the endpoints, which could potentially serve as entry points for malicious actors seeking to compromise data security. This proactive approach aids in safeguarding against data theft and other security threats.&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqjapevpav6xr9cvtyji.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqjapevpav6xr9cvtyji.png" alt="Identifying Vulnerabilities with Wazuh" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Security Configuration Assessment (SCA)
&lt;/h3&gt;

&lt;p&gt;Security Configuration Assessment (SCA) is an essential process that involves the thorough examination of monitored endpoints to identify misconfigurations that could potentially render these endpoints vulnerable to cyber attacks.&lt;/p&gt;

&lt;p&gt;SCA, as facilitated by Wazuh, continuously enhances the configuration posture of systems by adhering to recognized standards such as the Center for Internet Security (CIS), NIST, PCI-DSS, HIPAA, and various others.&lt;/p&gt;

&lt;p&gt;Wazuh's SCA module conducts routine scans on monitored endpoints with the primary goal of unveiling potential exposures of sensitive data or configuration inaccuracies. These scans meticulously evaluate the configurations of both the endpoints and the applications running on them. Policy files, containing rules designed for testing against the actual configurations, guide this assessment process.&lt;/p&gt;

&lt;p&gt;Through these scans, Wazuh's SCA module identifies various issues, including unnecessary services, default credentials, insecure protocols, and open ports on monitored endpoints. These findings are invaluable in preventing malicious actors from exploiting vulnerabilities to compromise data security.&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffp2hnk5erm5ywcht4l20.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffp2hnk5erm5ywcht4l20.png" alt="Security Configuration Assessment" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Analyzing Log Data for Enhanced Security
&lt;/h3&gt;

&lt;p&gt;Log data analysis is an integral procedure that involves scrutinizing the logs produced by various devices to uncover potential cyber threats and pinpoint security vulnerabilities and risks.&lt;/p&gt;

&lt;p&gt;Wazuh plays a pivotal role in this process by gathering security logs originating from multiple endpoints and employing decoders and rules to conduct a thorough analysis.&lt;/p&gt;

&lt;p&gt;One area of particular concern is the misuse of USB drives by disgruntled employees or malicious actors to pilfer sensitive data from an organization's endpoints. Wazuh addresses this threat by actively collecting and scrutinizing event logs generated when a USB drive is inserted into an endpoint.&lt;/p&gt;

&lt;p&gt;In a recent blog post, Wazuh showcases its capabilities in detecting both authorized and unauthorized USB drives through the utilization of a constant database (CDB) list containing authorized USB drives. This exemplifies how Wazuh's log data analysis aids in bolstering security measures and guarding against data theft and other potential risks.&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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7b3e7khx6h7spxzwu6w.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv7b3e7khx6h7spxzwu6w.png" alt="Analyzing Log Data for Enhanced Security" width="800" height="409"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>cybersecurity</category>
      <category>linux</category>
      <category>startup</category>
    </item>
    <item>
      <title>New in NextJS 14</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Mon, 30 Oct 2023 08:54:31 +0000</pubDate>
      <link>https://forem.com/augustin_ven/new-in-nextjs-14-5e2c</link>
      <guid>https://forem.com/augustin_ven/new-in-nextjs-14-5e2c</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyvkw9k6om61d7rsoo1rs.png" 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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyvkw9k6om61d7rsoo1rs.png" alt=" " width="800" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of Next.js 14
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Turbopack for Faster Development
&lt;/h3&gt;

&lt;p&gt;One of the standout features of Next.js 14 is Turbopack. It brings significant improvements to local server startup and code updates with Fast Refresh. Developers can expect up to a 53% faster local server startup and a remarkable 94% boost in code update speed. This is especially beneficial for large applications with complex module graphs, providing a smoother and more efficient development experience.&lt;/p&gt;

&lt;p&gt;Example: To experience the faster development, you can upgrade to Next.js 14 and create a new project using the command: npx create-next-app@latest.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Server Actions for Backend Functionality
&lt;/h3&gt;

&lt;p&gt;Next.js 14 introduces Server Actions, a powerful feature that simplifies the creation of API routes. It enables you to define functions that run securely on the server, eliminating the need for manual API route creation. This feature is built on web fundamentals like forms and the FormData Web API, making it accessible and user-friendly.&lt;/p&gt;

&lt;p&gt;Example🔥: Instead of manually creating an API route, you can define a function that runs on the server and call it directly from your React components, as shown in the example in the Next.js documentation.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Partial Prerendering for Dynamic Content .
&lt;/h3&gt;

&lt;p&gt;Partial Prerendering is a compiler optimization that enhances the performance of dynamic content. It combines the benefits of server-side rendering (SSR) and static-site generation (SSG) without introducing complexity. This feature streamlines the rendering process and reduces the need for multiple runtimes and configurations.&lt;/p&gt;

&lt;p&gt;Example🔥: Partial Prerendering generates a static shell based on Suspense boundaries, replacing fallbacks with dynamic components. This allows for fast initial static responses without additional network roundtrips.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Metadata Improvements
&lt;/h3&gt;

&lt;p&gt;Next.js 14 improves metadata handling by decoupling blocking and non-blocking metadata. This ensures a smoother user experience by sending essential metadata about the viewport, color scheme, and theme before rendering the page. Deprecated metadata options have been replaced with new APIs, enhancing flexibility and performance.&lt;/p&gt;

&lt;p&gt;Example🔥: You can adopt the new viewport and generateViewport options to control metadata, ensuring a more efficient loading process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pros of Next.js 14 ✔
&lt;/h2&gt;

&lt;p&gt;Improved Development Speed: The enhancements in Turbopack and Server Actions significantly speed up the development process, reducing development time and increasing productivity.&lt;/p&gt;

&lt;p&gt;Simplified API Creation: Server Actions simplify the creation of API routes, making it easier for developers to add backend functionality to their applications.&lt;/p&gt;

&lt;p&gt;Efficient Dynamic Content Rendering: Partial Prerendering improves the rendering of dynamic content, providing a fast and smooth user experience.&lt;/p&gt;

&lt;p&gt;Enhanced Metadata Handling: The new metadata options ensure a better user experience by optimizing metadata delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cons of Next.js 14 ❌
&lt;/h2&gt;

&lt;p&gt;Learning Curve: While the new features are beneficial, they may require developers to learn and adapt to the changes, especially if they are familiar with earlier versions of Next.js.&lt;/p&gt;

&lt;p&gt;Compatibility: Existing projects may require some adjustments to work seamlessly with the new features, which could lead to migration challenges.&lt;/p&gt;

&lt;h2&gt;
  
  
  In Conclusion ✨
&lt;/h2&gt;

&lt;p&gt;Next.js 14 brings a range of exciting features and improvements that enhance the development experience for web developers. While there may be a learning curve and migration challenges, the benefits in terms of speed, efficiency, and user experience are worth the investment.&lt;/p&gt;

&lt;p&gt;As with any new release, it's essential to explore and experiment with the new features to fully harness the power of Next.js 14 in your web development projects.&lt;/p&gt;

&lt;p&gt;Stay updated with Next.js and explore the possibilities it offers for your next web application.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Windows Volume License Activation Key Service - KMS</title>
      <dc:creator>Hiro Ventolero</dc:creator>
      <pubDate>Thu, 07 Sep 2023 09:19:59 +0000</pubDate>
      <link>https://forem.com/augustin_ven/windows-volume-license-activation-key-service-kms-294h</link>
      <guid>https://forem.com/augustin_ven/windows-volume-license-activation-key-service-kms-294h</guid>
      <description>&lt;h2&gt;
  
  
  Find Available Target Editions
&lt;/h2&gt;

&lt;p&gt;DISM.exe /Online /Get-TargetEditions&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use Step by Step
&lt;/h2&gt;

&lt;p&gt;For example you want to install a license for Windows 10 Enterprise Operating System&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;slmgr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/ipk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;WINDOWS-10-ENTERPRISE-LICENSE&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; 
&lt;/span&gt;&lt;span class="n"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;refer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;below&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;license&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Register a New KMS Server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;slmgr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/skms&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;]:[&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; 
&lt;/span&gt;&lt;span class="n"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;refer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;to&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;below&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Activate the installed license&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;slmgr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/ato&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Convert Server Standard 2019 Evaluation to Server Standard 2019
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;DISM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/online&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/Set-Edition:ServerStandard&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/ProductKey:N69G4-B89J2-4G8F4-WWYCC-J464C&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/AcceptEula&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How To Activate
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;slmgr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/ipk&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;XXXXX-XXXXX-XXXXX-XXXXX-XXXXX&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;slmgr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/skms&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="p"&gt;]:[&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;slmgr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/ato&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;slmgr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;/dlv&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  License Key
&lt;/h2&gt;

&lt;p&gt;Windows Server 2019 Datacenter      WMDGN-G9PQG-XVVXX-R3X43-63DFG&lt;br&gt;
Windows Server 2019 Standard        N69G4-B89J2-4G8F4-WWYCC-J464C&lt;br&gt;
Windows Server 2019 Essentials      WVDHN-86M7X-466P6-VHXV7-YY726&lt;/p&gt;

&lt;p&gt;Windows Server 2016 Datacenter      CB7KF-BWN84-R7R2Y-793K2-8XDDG&lt;br&gt;
Windows Server 2016 Standard        WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY&lt;br&gt;
Windows Server 2016 Essentials      JCKRF-N37P4-C2D82-9YXRT-4M63B&lt;/p&gt;

&lt;p&gt;Windows Server 2012 R2 Datacenter   Y4TGP-NPTV9-HTC2H-7MGQ3-DV4TW&lt;br&gt;
Windows Server 2012 R2 Standard     DBGBW-NPF86-BJVTX-K3WKJ-MTB6V&lt;br&gt;
Windows Server 2012 R2 Essentials   K2XGM-NMBT3-2R6Q8-WF2FK-P36R2&lt;/p&gt;

&lt;p&gt;Windows 10 Professional             W269N-WFGWX-YVC9B-4J6C9-T83GX&lt;br&gt;
Windows 10 Professional N           MH37W-N47XK-V7XM9-C7227-GCQG9&lt;br&gt;
Windows 10 Enterprise               NPPR9-FWDCX-D2C8J-H872K-2YT43&lt;br&gt;
Windows 10 Enterprise N             DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4&lt;br&gt;
Windows 10 Education                NW6C2-QMPVW-D7KKK-3GKT6-VCFB2&lt;br&gt;
Windows 10 Education                2WH4N-8QGBV-H22JP-CT43Q-MDWWJ&lt;br&gt;
Windows 10 Enterprise LTSC 2019     M7XTQ-FN8P6-TTKYV-9D4CC-J462D&lt;br&gt;
Windows 10 Enterprise N LTSC 2019   92NFX-8DJQP-P6BBQ-THF9C-7CG2H&lt;/p&gt;

&lt;h2&gt;
  
  
  Online KMS Server Host Address
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;kms8.msguides.com&lt;/li&gt;
&lt;li&gt;kms.digiboy.ir&lt;/li&gt;
&lt;li&gt;hq1.chinancce.com&lt;/li&gt;
&lt;li&gt;54.223.212.31&lt;/li&gt;
&lt;li&gt;kms.cnlic.com&lt;/li&gt;
&lt;li&gt;kms.chinancce.com&lt;/li&gt;
&lt;li&gt;kms.ddns.net&lt;/li&gt;
&lt;li&gt;franklv.ddns.net&lt;/li&gt;
&lt;li&gt;k.zpale.com&lt;/li&gt;
&lt;li&gt;m.zpale.com&lt;/li&gt;
&lt;li&gt;mvg.zpale.com&lt;/li&gt;
&lt;li&gt;kms.shuax.com&lt;/li&gt;
&lt;li&gt;kensol263.imwork.net:1688&lt;/li&gt;
&lt;li&gt;xykz.f3322.org&lt;/li&gt;
&lt;li&gt;kms789.com&lt;/li&gt;
&lt;li&gt;dimanyakms.sytes.net:1688&lt;/li&gt;
&lt;li&gt;kms.03k.org:1688&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>operatingsystem</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
