<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[asrvd/ashish - hashnode]]></title><description><![CDATA[asrvd/ashish - hashnode]]></description><link>https://h.asrvd.me</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 04:50:41 GMT</lastBuildDate><atom:link href="https://h.asrvd.me/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Introducing Disecure: Secure your Discord servers using Pangea's powerful security services!]]></title><description><![CDATA[Introduction
Hashnode announced the Pangea Securathon on November 1st, and after spending a decent amount of time thinking about what I should build, I decided to build a Discord bot after taking inspiration from the suggested projects in the hackath...]]></description><link>https://h.asrvd.me/introducing-disecure-secure-your-discord-servers-using-pangeas-powerful-security-services</link><guid isPermaLink="true">https://h.asrvd.me/introducing-disecure-secure-your-discord-servers-using-pangeas-powerful-security-services</guid><category><![CDATA[PangeaSecurathon]]></category><category><![CDATA[pangea]]></category><dc:creator><![CDATA[ashish]]></dc:creator><pubDate>Wed, 15 Nov 2023 21:10:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1700083007999/4ca58641-6eb4-4416-9541-6f877eed623b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p><a target="_blank" href="https://hashnode.com">Hashnode</a> announced the <a target="_blank" href="https://hashnode.com/hackathons/pangea">Pangea Securathon</a> on November 1st, and after spending a decent amount of time thinking about what I should build, I decided to build a Discord bot after taking inspiration from the suggested projects in the hackathon page! Here's everything about what I built and how I built it.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://vimeo.com/889054593?share=copy">https://vimeo.com/889054593?share=copy</a></div>
<p> </p>
<h2 id="heading-whats-disecure">What's Disecure?</h2>
<p>Disecure (Discord + secure) is a discord bot made by me for the Pangea Securathon. It's the only bot you will ever need to keep your server safe from malicious/suspicious links/files or any other thing. Disecure uses Pangea's powerful security services to provide the following features -</p>
<p>- <strong>Auto Redact</strong> - Automatically redacts messages that contain profanity/private information like emails, phone numbers, credit card numbers, etc.</p>
<p>- <strong>Auto URL Scan</strong> - Automatically scans URLs present in messages for malicious content and deletes it if a malicious URL is found.</p>
<p>- <strong>Auto File Scan</strong> - Automatically scans files uploaded to the server for malicious content and deletes it if a malicious file is found.</p>
<p>- <strong>Logging</strong> - Logs reports of malicious content found in messages, URLs, and files to a channel in the server for you to review.</p>
<h2 id="heading-why-did-i-build-disecure">Why did I build Disecure?</h2>
<p>I've been an active Discord user since the last 3 years and the one thing that has always upset me about discord is the huge number of spams and scams that happen in the discord servers. People lose their accounts by clicking on some kind of suspicious link that doesn't appear to be suspicious! Not to mention the amount of malware that people accidentally download from the servers!</p>
<p>Pangea's security services are exactly what I needed to build something like Disecure which can scan files and messages and instantly delete the messages if any suspicious activity is found. Apart from this Disecure can also redact personal information which might get leaked accidentally in servers like your API keys, credit card numbers, phone numbers, emails or anything. Disecure scans each and every message sent in your servers to keep it safe and secure!</p>
<h2 id="heading-how-did-i-build-disecure">How did I build Disecure?</h2>
<p>Disecure is built upon the Discord API using the <a target="_blank" href="https://github.com/Rapptz/discord.py">Discord.py</a> wrapper &amp; Pangea's <a target="_blank" href="https://github.com/pangeacyber/pangea-python">Python SDK</a>. For logging messages I use a simple table from free tier of <a target="_blank" href="https://supabase.com">Supabase</a>.</p>
<p>Firstly I created a discord bot account using the <a target="_blank" href="https://discord.com/developers/applications">Developer Portal</a> and got my Bot's client ID &amp; client secret. The next step was creating a new account on <a target="_blank" href="https://pangea.cloud">Pangea</a> and then I enabled the services I needed - Redact, File Scan, URL Intel and then I grabbed the respective tokens for each of the services. The last thing was creating a new <a target="_blank" href="https://supabase.com">Supabase</a> project and then get the project URL and project Key both of which are needed to connect to your database.</p>
<p>Next, I created a new table named <code>logger</code> in the Supabase project using the following query in the SQL editor -</p>
<pre><code class="lang-sql"><span class="hljs-keyword">create</span> <span class="hljs-keyword">table</span>
  public.logger (
    <span class="hljs-keyword">id</span> <span class="hljs-built_in">bigint</span> <span class="hljs-keyword">generated</span> <span class="hljs-keyword">by</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">as</span> <span class="hljs-keyword">identity</span>,
    created_at <span class="hljs-built_in">timestamp</span> <span class="hljs-keyword">with</span> <span class="hljs-built_in">time</span> zone <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">now</span>(),
    guild_id <span class="hljs-built_in">bigint</span> <span class="hljs-keyword">not</span> <span class="hljs-literal">null</span>,
    channel_id <span class="hljs-built_in">bigint</span> <span class="hljs-literal">null</span>,
    <span class="hljs-keyword">constraint</span> logger_pkey primary <span class="hljs-keyword">key</span> (guild_id)
  ) <span class="hljs-keyword">tablespace</span> pg_default;
</code></pre>
<p>Next, I started writing the actual code for the bot. You can look at this <a target="_blank" href="https://github.com/Rapptz/discord.py/blob/master/examples/basic_bot.py">Basic bot example</a> to get an idea of what a discord.py bot looks like. For this bot, we need to scan every message sent in the server. Discord.py has an in-built event handler named <code>on_message</code> that's triggered every time a new message is sent in your server. Here's what the code would look like -</p>
<pre><code class="lang-python"><span class="hljs-meta">@bot.event</span>
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">on_message</span>(<span class="hljs-params">message: discord.Message</span>):</span>
    <span class="hljs-comment"># ignore the message if it's from the bot itself</span>
    <span class="hljs-keyword">if</span> message.author == bot.user:
        <span class="hljs-keyword">return</span>

    print(message.content) <span class="hljs-comment"># do something with the message content</span>
</code></pre>
<p>Now, by using Pangea's python SDK we can check the message content and delete it if it contains something malicious or contains someone's personal information.</p>
<pre><code class="lang-python"><span class="hljs-meta">@bot.event</span>
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">on_message</span>(<span class="hljs-params">message: discord.Message</span>):</span>
        <span class="hljs-keyword">if</span> message.author == bot.user:
            <span class="hljs-keyword">return</span>

        <span class="hljs-keyword">for</span> word <span class="hljs-keyword">in</span> message.content.split(): <span class="hljs-comment"># don't check urls as if have another check for it</span>
            <span class="hljs-keyword">if</span> url_regex.match(word):
                <span class="hljs-keyword">return</span>

        response = redact.redact(message.content)

        <span class="hljs-comment"># check if something was redacted from the text</span>
        <span class="hljs-keyword">if</span> response.status.lower() == <span class="hljs-string">"success"</span> <span class="hljs-keyword">and</span> response.result.count &gt; <span class="hljs-number">0</span>:
            <span class="hljs-keyword">await</span> message.delete() <span class="hljs-comment"># instantly delete the message</span>
            <span class="hljs-keyword">await</span> message.channel.send(
                <span class="hljs-string">f"1 message redacted from <span class="hljs-subst">{message.author.mention}</span>, redacted message: <span class="hljs-subst">{response.result.redacted_text}</span>"</span>,
                delete_after=<span class="hljs-number">5</span>,
            ) <span class="hljs-comment"># warn the message author about it</span>
</code></pre>
<p>I added the other utilities using the same method and the added a way for the bot to log about suspicious user activities in a separate channel for the server moderators/owner to review them and take action if needed against the user. Steps to add logging channel for your server are there in the <a target="_blank" href="https://github.com/asrvd/disguard#readme">Project README</a>.</p>
<h2 id="heading-viewing-your-servers-detailed-reports">Viewing your Server's detailed reports</h2>
<p>Since everything is done using Pangea, all of the cases and analytics regarding malicious activities in your server can be checked using Pangea's dashboard. Pangea has a very nice dashboard with graphs and all the analytics you need to check what's happening in your server!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700062490649/79300478-b9e3-457c-b71f-50098c456dbf.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-challenges-i-faced">Challenges I faced</h2>
<p>To be honest, working with Pangea's SDK and APIs went very smoothly all thanks to their super nice <a target="_blank" href="https://pangea.cloud/docs">Documentation</a>! The only challenge I faced was learning to build a discord bot and integrating it with Pangea's SDK.</p>
<h2 id="heading-usage">Usage</h2>
<p>Disecure is not hosted anywhere as I don't have any VPS, the only way you can use it right now is by self hosting which is quite easy! Follow the <a target="_blank" href="https://github.com/asrvd/disguard#readme">Project's README</a> for a detailed usage guide!</p>
<h2 id="heading-resources">Resources</h2>
<ul>
<li><p><a target="_blank" href="https://github.com/asrvd/disguard">Github Repository</a></p>
</li>
<li><p><a target="_blank" href="https://pangea.cloud/">Pangea Cloud</a></p>
</li>
<li><p><a target="_blank" href="https://hashnode.com">Hashnode</a></p>
</li>
<li><p><a target="_blank" href="https://discordpy.readthedocs.io/en/stable/">Discord.py Docs</a></p>
</li>
</ul>
<h2 id="heading-ending-note">Ending note</h2>
<p>I really loved working with <a target="_blank" href="https://pangea.cloud">Pangea</a> to build this project. I would like to thank <a target="_blank" href="https://hashnode.com">Hashnode</a> and <a target="_blank" href="https://pangea.cloud">Pangea</a> for providing me this opportunity to work on this amazing project.</p>
<p>Thanks a lot for reading!</p>
]]></content:encoded></item><item><title><![CDATA[Introducing Feedright: Getting Feedback made easier using widgets!]]></title><description><![CDATA[Introduction
Getting feedback from our users/customers is the most important thing we need to do if we want to grow our product and make it appealing to more people. But doing it isn't as easier as it looks. Providing a mail address for people to giv...]]></description><link>https://h.asrvd.me/introducing-feedright-getting-feedback-made-easier-using-widgets</link><guid isPermaLink="true">https://h.asrvd.me/introducing-feedright-getting-feedback-made-easier-using-widgets</guid><category><![CDATA[Appwrite Hackathon]]></category><category><![CDATA[Appwrite]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[Tailwind CSS]]></category><category><![CDATA[React]]></category><dc:creator><![CDATA[ashish]]></dc:creator><pubDate>Thu, 15 Jun 2023 06:42:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1686810775519/9726ce1c-701a-407a-900e-5fb7cf6caf4e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Getting feedback from our users/customers is the most important thing we need to do if we want to grow our product and make it appealing to more people. But doing it isn't as easier as it looks. Providing a mail address for people to give feedback doesn't work most of the times and building a custom solution is time-consuming.</p>
<p>This is where <a target="_blank" href="https://feedright.vercel.app">Feedright</a> comes in! Feedright lets you create embeddable widgets for all of your sites for people to provide feedback along with adding screenshots to provide more context. You also get a personal dashboard to view and manage all your widgets!</p>
<h2 id="heading-inspiration">Inspiration</h2>
<p>Being an indie hacker and solo developer, I have shipped a lot of projects but I rarely see people giving feedback on my projects. Making them open-sourced allows the users to use GitHub to provide feedback or issue a bug report but not everyone is on GitHub. This is why I felt the need to create a custom solution to fix this thing. Feedright allows people to get started with a working widget in a few seconds along with a nice dashboard.</p>
<h2 id="heading-team-details">Team Details</h2>
<p>This app was solo developed by me -</p>
<ul>
<li>ashish - <a target="_blank" href="https://twitter.com/_asheeshh">@_asheeshh</a></li>
</ul>
<h2 id="heading-features">Features</h2>
<h3 id="heading-create-widgets-for-every-site">Create widgets for every site</h3>
<p>Feedright lets you create different widgets for each of your sites making it easier to manage the feedbacks you receive. Just log in with GitHub and you can start creating them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1686807394935/da9d5b1d-ebc8-4852-9e56-da380a1b9175.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-personal-dashboard">Personal dashboard</h3>
<p>Feedright provides you with a personal dashboard to let you create widgets as well as view all the feedback for them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1686807470741/9e19a15f-0b87-45d9-83d4-0adccbf7328b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-easy-to-use-widget">Easy-to-use widget</h3>
<p>The widget is made keeping in mind the user experience. Just click on the widget icon and it will guide you till you submit your feedback!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1686807558738/396d4108-d30c-4daa-b41a-10f3849ef6c6.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-add-screenshots-with-feedback">Add screenshots with feedback</h3>
<p>Your users can even attach a screenshot or any other image which provides more context to the feedback. The screenshots are viewable along with the feedback as well!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1686807654847/0e24a8c8-ea23-4fb0-a0ea-eb00c6651683.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-tech-stack">Tech Stack</h2>
<p>Feedright was made using the following amazing pieces of tech -</p>
<ul>
<li><p><a target="_blank" href="https://nextjs.org">NextJS</a></p>
</li>
<li><p><a target="_blank" href="https://tailwindcss.com">Tailwind CSS</a></p>
</li>
<li><p><a target="_blank" href="https://appwrite.io">Appwrite</a></p>
</li>
<li><p><a target="_blank" href="https://cloud.appwrite.io">Appwrite Cloud</a></p>
</li>
<li><p><a target="_blank" href="https://next-auth.js.org">NextAuth</a></p>
</li>
<li><p><a target="_blank" href="https://vercel.com">Vercel</a></p>
</li>
<li><p><a target="_blank" href="https://github.com">GitHub</a></p>
</li>
</ul>
<h2 id="heading-how-did-i-use-appwrite">How did I use Appwrite?</h2>
<p>The whole backend of Feedright depends upon Appwrite and it's amazing how Appwrite handles everything from storing data to storing images making it the perfect choice for Feedright.</p>
<p>Feedright uses the <strong>Database</strong> and <strong>Storage</strong> feature of Appwrite. All the widget and feedback data are stored in the Appwrite database. The screenshots provided by the users are stored in a bucket using Appwrite Storage.</p>
<p>I didn't use the Appwrite auth option as I'm not storing any user information apart from a unique id to store widgets thus letting them feel at ease while using the app that no unnecessary data is being stored by the app!</p>
<h2 id="heading-walkthrough">Walkthrough</h2>
<ul>
<li><p>Head over to the app - <a target="_blank" href="https://feedright.vercel.app">Feedright</a></p>
</li>
<li><p>Sign in the app using your GitHub account. (I'm planning to add Google OAuth as well soon)</p>
</li>
<li><p>Click on the <strong>Your Dashboard</strong> button, it will take you to your dashboard.</p>
</li>
<li><p>Now just follow this video to create your first widget 👇</p>
<p>  <div class="embedded-content"><a class="embed-card" data-card-width="600px" data-card-key="2e4d628b39a64b99917c73956a16b477" data-card-controls="0" data-card-theme="light" href="https://vimeo.com/836428185?share=cop"></a></div>]</p>
</li>
<li><p>Just copy the embed script and paste it into your website's code to make the widget appear on your site.</p>
</li>
</ul>
<h2 id="heading-challenges">Challenges</h2>
<ul>
<li><p><strong>Using Next.js v13 with Appwrite</strong> - This was a very challenging and rewarding experience for me as I got to learn a lot about Next.js v13 along with using <a target="_blank" href="https://www.npmjs.com/package/appwrite">Appwrite SDK</a> with it. Thanks to the easy and well-written documentation both of them have made it quite easier for me to figure out things.</p>
</li>
<li><p><strong>Creating embeddable widgets</strong> - If I am honest, this was my very first time creating embeddable widgets purely using React. I spent days researching how to achieve this and was finally able to do this using <a target="_blank" href="https://parceljs.org/">Parcel</a> to build the widget and then expose the file using the <code>/public/</code> folder in Next.js.</p>
</li>
</ul>
<h2 id="heading-development">Development</h2>
<p>All the code for Feedright is open-sourced on GitHub in this repository. Instructions for running the app locally are given on the README file.</p>
<h2 id="heading-important-links">Important Links</h2>
<ul>
<li><p><a target="_blank" href="https://feedright.vercel.app">Live App</a></p>
</li>
<li><p><a target="_blank" href="https://hashnode.com">Hashnode</a></p>
</li>
<li><p><a target="_blank" href="https://cloud.appwrite.io">Appwrite Cloud</a></p>
</li>
<li><p><a target="_blank" href="https://github.com/asrvd/feedright">Source Code</a></p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Thank you so much for reading the article, thanks to Hashnode and Appwrite for allowing me to work on this wonderful project, I hope that this app will have a positive impact on the developer ecosystem, looking forward to everyone's feedback ;)</p>
]]></content:encoded></item><item><title><![CDATA[I built a chrome extension that can explain code blocks to you right from the site: Introducing Syntaxify ✨]]></title><description><![CDATA[Introduction
As a developer, we often find ourselves struggling with understanding complex code blocks on different sites and resources and spend hours trying to debug and understand them. Reading code written by others is a cumbersome task but it do...]]></description><link>https://h.asrvd.me/i-built-a-chrome-extension-that-can-explain-code-blocks-to-you-right-from-the-site-introducing-syntaxify</link><guid isPermaLink="true">https://h.asrvd.me/i-built-a-chrome-extension-that-can-explain-code-blocks-to-you-right-from-the-site-introducing-syntaxify</guid><category><![CDATA[MindsDBHackathon]]></category><category><![CDATA[mindsdb]]></category><dc:creator><![CDATA[ashish]]></dc:creator><pubDate>Sun, 30 Apr 2023 06:58:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1682846495898/40330337-599b-4454-85b4-5f810c69f4c8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>As a developer, we often find ourselves struggling with understanding complex code blocks on different sites and resources and spend hours trying to debug and understand them. Reading code written by others is a cumbersome task but it doesn't have to be! What if I told you that there is an extension that can explain those code blocks to you in a matter of seconds?</p>
<p>Introducing Syntaxify, a powerful tool that can help you understand complex code blocks in a simple and easy-to-understand way. Syntaxify lets you select code blocks right from the site and then get its explanation in seconds using <a target="_blank" href="https://mindsdb.com">MindsDB</a>'s excellent NLP integrations with OpenAI.</p>
<p>This extension is especially useful for beginners who are just starting out with coding and need some extra help understanding complex concepts. It can also benefit experienced developers who want to save time and speed up their workflow.</p>
<p>Want to learn more about this tool and how it was made? Keep reading!</p>
<h2 id="heading-creating-the-extension">Creating the Extension</h2>
<p>The extension was made by me from scratch and it was not at all an easy task. Being my first chrome extension, I had to go through a lot of resources and references to create it. The first step to creating this extension is to create an NLP model using <a target="_blank" href="https://mindsdb.com">MindsDB</a>.</p>
<ul>
<li><p>Create a free account on <a target="_blank" href="https://mindsdb.com">MindsDB</a> to get access to their cloud dashboard.</p>
</li>
<li><p>Create your OpenAI model using the Editor, you can change the name of columns and model to whatever you want.</p>
<pre><code class="lang-sql">  <span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">MODEL</span> code_explainer
  PREDICT explanation
  <span class="hljs-keyword">USING</span>
      <span class="hljs-keyword">engine</span> = <span class="hljs-string">'openai'</span>,              
      prompt_template = <span class="hljs-string">'provide a concise and easy to understand explanation of the given code block:{{block}}, make sure it can be easily understood even by beginners'</span>;
</code></pre>
</li>
<li><p>Once you have created your model, It's time to integrate it with your extension, I made my backend using Flask (Python) and used the <a target="_blank" href="https://pypi.org/project/mindsdb-sdk/">MindsDB Python SDK</a> to connect with my MindsDB instance.</p>
<p>  We are using Flask to create the API. Firstly, we need to get the URL arguments that contain the code block and then we feed the code block data to our MindsDB model using the Python SDK which returns a DataFrame. The DataFrame contains our code explanation which we can return as response from the API.</p>
</li>
</ul>
<pre><code class="lang-python">    <span class="hljs-keyword">from</span> flask <span class="hljs-keyword">import</span> Flask, request
    <span class="hljs-keyword">import</span> mindsdb_sdk <span class="hljs-keyword">as</span> mdb
    <span class="hljs-keyword">import</span> urllib.parse
    <span class="hljs-keyword">import</span> dotenv

    app = Flask(__name__)

    dotenv.load_dotenv()

    EMAIL = dotenv.get_key(<span class="hljs-string">".env"</span>, <span class="hljs-string">"EMAIL"</span>)
    PASSWORD = dotenv.get_key(<span class="hljs-string">".env"</span>, <span class="hljs-string">"PSWD"</span>)


    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_explanation</span>(<span class="hljs-params">code: str</span>) -&gt; str:</span>
        <span class="hljs-string">"""Get explanation for a given code

        Args:
            code (str): code to get explanation for

        Returns:
            str: explanation for the given code
        """</span>
        server = mdb.connect(login=EMAIL, password=PASSWORD)
        project = server.get_project(<span class="hljs-string">"mindsdb"</span>)

        <span class="hljs-comment"># replace double quotes with single quotes</span>

        code = code.replace(<span class="hljs-string">'"'</span>, <span class="hljs-string">"'"</span>)

        <span class="hljs-comment"># // escape single quotes and double quotes and semicolons from code by adding \ before them</span>

        escapedCode = code.replace(<span class="hljs-string">"'"</span>, <span class="hljs-string">"\\'"</span>).replace(<span class="hljs-string">'"'</span>, <span class="hljs-string">'\\"'</span>).replace(<span class="hljs-string">";"</span>, <span class="hljs-string">"\\;"</span>)

        q = project.query(
            <span class="hljs-string">f"""
            SELECT article, highlights
            FROM cex
            WHERE article = "<span class="hljs-subst">{escapedCode}</span>"
            USING max_tokens = 1000;
        """</span>
        )

        df = q.fetch()
        result = df.iloc[<span class="hljs-number">0</span>][<span class="hljs-string">"highlights"</span>]
        print(result)
        <span class="hljs-keyword">return</span> result


<span class="hljs-meta">    @app.route("/")</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">explainer</span>():</span>
        print(EMAIL, PASSWORD)
        code = request.args.get(<span class="hljs-string">"code"</span>)
        <span class="hljs-keyword">if</span> code:
            decoded_code = urllib.parse.unquote(code)
            <span class="hljs-keyword">return</span> get_explanation(decoded_code)

        <span class="hljs-keyword">return</span> <span class="hljs-string">"No code provided"</span>


    <span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
        app.run(debug=<span class="hljs-literal">True</span>)
</code></pre>
<ul>
<li>Once your backend is ready, you can start building the extension and connect your backend to it, Since the extension code is a bit complex, it would be unnecessary to include it here, but the source code can be seen <a target="_blank" href="https://github.com/asrvd/syntaxify">here</a></li>
</ul>
<h2 id="heading-why-andamp-how-did-i-use-mindsdb">Why &amp; How Did I Use MindsDB?</h2>
<p>I need two important things to build this tool - a database and an AI model. And MIndsDB is the perfect mix of both - a database with inbuilt AI-ML capabilities. Along with being able to run ML models right in your database, I could even use NLP through HuggingFace and OpenAI models and that was exactly what I needed.</p>
<p>The tool uses MindsDB to store all the generated explanations as well as provides the explanations using OpenAI's model! In the future, I would like to implement authentication in the app and MindsDB will be used to store user data as well! It's amazing how you can leverage MindsDB to replace most of the backend tools you might need to build an AI/ML app.</p>
<h2 id="heading-usage">Usage</h2>
<p>Here comes the most interesting part, you can use the extension right in your browser and it takes just a few steps.</p>
<ul>
<li><p>Clone the <a target="_blank" href="https://github.com/asrvd/syntaxify">Syntaxify GitHub Repository</a> locally using git CLI or downloading it as zip file.</p>
</li>
<li><p>Inside the repository, you would see a <code>dist</code> folder. That's the extension that we need to load.</p>
</li>
<li><p>Open Chrome, and then go to the <code>Settings &gt; Extensions</code> and enable **Developer Mode**.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682844566400/3ab5ffb8-ee2a-4283-8d79-c46b88b3b4f8.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Now click on <strong>Load Unpacked</strong> and then select the <code>dist</code> folder that we cloned in step 1.</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682844655074/cce91366-c513-43a2-bf79-b557c26a5be7.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Your extension is loaded and ready to use now. Watch this video to learn how to use it!</p>
</li>
</ul>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/8oO1B5kAEMA">https://youtu.be/8oO1B5kAEMA</a></div>
<p> </p>
<h2 id="heading-links">Links</h2>
<ul>
<li><p>Extension Repository - https://github.com/asrvd/syntaxify</p>
</li>
<li><p>Backend Repository - <a target="_blank" href="https://github.com/asrvd/stx-backend">https://github.com/asrvd/stx-backend</a></p>
</li>
<li><p>MindsDB - https://mindsdb.com</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In conclusion, Syntaxify is a game-changing tool that can make the life of developers easier by providing an easy-to-understand explanation of complex code blocks. It can help beginners learn to code faster and more efficiently while also benefiting experienced developers by saving them valuable time and effort. With this extension, you can improve your coding skills, become a more productive developer, and ultimately, create better software.</p>
<p>Thanks a lot <a target="_blank" href="https://hashnode.com">Hashnode</a> and <a target="_blank" href="https://mindsdb.com">MindsDB</a> for giving me this amazing opportunity to work on this project. I learned a lot from this hackathon build.</p>
]]></content:encoded></item><item><title><![CDATA[How I became a full-stack web developer and won the Hashnode Hackathon as a student: Dev Retro 2022]]></title><description><![CDATA[What is this blog about?
This blog is all about my last one year of work and experiences that helped me become a full-stack web developer, become an active technical content writer with more than 50k blog reads, win hackathons and land freelance jobs...]]></description><link>https://h.asrvd.me/how-i-became-a-full-stack-web-developer-and-won-the-hashnode-hackathon-as-a-student-dev-retro-2022</link><guid isPermaLink="true">https://h.asrvd.me/how-i-became-a-full-stack-web-developer-and-won-the-hashnode-hackathon-as-a-student-dev-retro-2022</guid><category><![CDATA[#DevRetro2022]]></category><category><![CDATA[Productivity]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[ashish]]></dc:creator><pubDate>Thu, 05 Jan 2023 13:30:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1672925111727/1be105d6-1f70-4e85-8f78-1281d8b66a8a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-this-blog-about">What is this blog about?</h2>
<p>This blog is all about my last one year of work and experiences that helped me become a full-stack web developer, become an active technical content writer with more than 50k blog reads, win hackathons and land freelance jobs in some well-known companies in tech.</p>
<h2 id="heading-how-it-all-started">How it all started?</h2>
<p>Let's rewind back in time to January 2022. I was an 18-year-old student who was about to graduate from high school and I was really interested in web development and open-source. Back then, I used to look at web apps made by others and it used to fascinate me a lot. As you may already have guessed, I had already started learning about aspects of web development and was learning JavaScript and I used to make small projects using HTML, CSS and JavaScript and then I would add them to my GitHub account to learn about open-source development.</p>
<p>Soon, after I came to know about dynamic web apps and that's where web frameworks and libraries like React and Vue came in. I started learning about React soon after (around January end) from Scrimba and created my first React project which was a basic [truth or dare generator](<a target="_blank" href="https://github.com/asrvd/tod-app">https://github.com/asrvd/tod-app</a>). And then there was no going back.</p>
<h2 id="heading-learning-frontend-and-content-writing">Learning Frontend and Content Writing</h2>
<p>Once I got into React, my first aim was to master Frontend Development and also start writing blogs. As I kept on learning about new things, I started writing about them in my blogs which would also help me research the topic better and get a better understanding of it. Once I was confident enough with JSX, CSS Frameworks, and React Hooks, I started exploring more Frontend Frameworks and writing about them. Most of the time, I would make a simple app and add it as a tutorial section in my blog posts.</p>
<p>By this time, I had already made some nice projects using React, one of which was a [Terminal Styled Portfolio Website](https://github.com/asrvd/ashterm) which was my first ever project to cross 50+ stars on GitHub naturally. The next thing on my bucket list was mastering Next.js and becoming a full-stack web developer.</p>
<h2 id="heading-the-full-stack-tag">The Full-Stack Tag</h2>
<p>Learning Next.js was one of the best decisions as it helped me get into full-stack development without getting into some complex setup. It also helped me get a better understanding of APIs and Databases. I also made some more cool projects like a lyrics API with frontend, a GitHub stats generator, An app to create polls and share them and a few others. While building and sharing the projects on GitHub, more people started finding my projects and my GitHub stars and followers increased a lot. I gained around 120 followers and more than 350 stars in the last 11 months on GitHub. Apart from that [my blogs](https://dev.to/asheeshh) also started performing well. By July 2022 I had already become a full-stack web developer and content writer.</p>
<h2 id="heading-winning-my-first-hackathon">Winning my first Hackathon</h2>
<p>Hashnode launched the [Planetscale x Hashnode Hackathon](<a target="_blank" href="https://townhall.hashnode.com/planetscale-hackathon">https://townhall.hashnode.com/planetscale-hackathon</a>) in July and it was the perfect way for me to test my Web Dev skills! It took around 2 weeks to find a great idea which was basically an app to create widgets where you can add all your sponsor links. I spent the remaining 2 weeks building the app. Here is the [repository](https://github.com/asrvd/ponsor) for the app and it's live [here](https://ponsor.vercel.app). To be honest, I didn't even expect my project to win because there were literally hundreds of projects and most of them were from seasoned Web Developers.</p>
<p>But but but-I made it! My project was in the [top 5](<a target="_blank" href="https://townhall.hashnode.com/planetscale-x-hashnode-hackathon-winners">https://townhall.hashnode.com/planetscale-x-hashnode-hackathon-winners</a>) in the Hackathon and that was literally an unbelievable moment for me. Winning the first-ever hackathon I participated in was like a dream come true for me. And I still can't thank Hashnode enough for bringing out this amazing opportunity. This helped me get a lot more confident with my skills.</p>
<h2 id="heading-landing-freelance-jobs-in-tech">Landing freelance jobs in tech</h2>
<p>By August 2022, I was confident enough to apply for freelance or part-time job positions in tech, most of which were for content writing positions. My first freelance position was at [Kinsta](https://kinsta.com) as a technical content writer. And the second was at [Scrimba](https://scrimba.com} as a technical content writer.</p>
<p>Getting these opportunities would never have been possible if I didn't start blogging. Blogging really played a major role in my tech career as a beginner.</p>
<h2 id="heading-open-source">Open Source</h2>
<p>Open Source was the next big thing that helped me a lot in 2022. Being on GitHub and actively contributing to other Open-Source projects helped me a lot to get to know what production scale apps look like and how they are maintained. I also became a maintainer for the [create-t3-app](https://github.com/t3-oss/create-t3-app) project which is a CLI tool to scaffold a t3 app based on the [t3 stack](https://create.t3.gg).</p>
<p>Also, a big shoutout to [Anthony Campolo](<a target="_blank" href="https://twitter.com/ajcwebdev">https://twitter.com/ajcwebdev</a>) for being my first-ever GitHub Sponsor, it motivated me a lot to keep working on Open Source projects.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Looking back at 2022, I think it has been one of the best years of my life and I was able to achieve a lot. Most of which was achieved just by working consistently. Believe me, when I say, you only need to work consistently to become a successful developer. YouTube Tutorials and Blogs are all good but there's no point in watching/reading them if you don't actually put the knowledge to practical use. Let others know that you actually know what you have learned. And to do that, you just need to do one thing - make more projects.</p>
<p>This blog wasn't meant to provide guidance or anything. I just wanted to share my experience of 2022 but maybe it would motivate some of you, I hope so! So, here's to yet another year of accomplishments and learnings, cheers!! 🥂</p>
]]></content:encoded></item><item><title><![CDATA[How blogging helped me land a part time job in tech?]]></title><description><![CDATA[Introduction
Blogging is no doubt one of the major ways of sharing knowledge, experience, and resources with the world. The tech community is also using and has been using blogging a lot to share things related to tech - be it a tutorial on a new Jav...]]></description><link>https://h.asrvd.me/how-blogging-helped-me-land-a-part-time-job-in-tech</link><guid isPermaLink="true">https://h.asrvd.me/how-blogging-helped-me-land-a-part-time-job-in-tech</guid><category><![CDATA[Career]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[4articles4weeks]]></category><category><![CDATA[#week4]]></category><dc:creator><![CDATA[ashish]]></dc:creator><pubDate>Fri, 09 Sep 2022 04:14:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1662696867912/iMSbVpGur.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Blogging is no doubt one of the major ways of sharing knowledge, experience, and resources with the world. The tech community is also using and has been using blogging a lot to share things related to tech - be it a tutorial on a new JavaScript framework, a list of resources a developer can use, technical reviews of products, and even experiences of people who are related to tech like the current one you’re reading. </p>
<p>This blog is basically about how I decided to start blogging, why did I decide to start blogging, and finally how was I able to land a part time technical writing job with a very decent pay <a target="_blank" href="https://scrimba.com">@Scrimba</a>.</p>
<h2 id="heading-the-idea">The Idea</h2>
<p>Let’s go one year back in time and start from right there, I was a 18 year old student who had been programming since the last one year and then got interested in web development. I started learning about HTML, CSS, JavaScript, and then eventually about JavaScript frameworks. By the end of the year, I was somewhat of a frontend dev myself and I continued to learn more about new frameworks and tech related to web from blogs and videos. </p>
<p>But, while reading the blogs, I found that most of the those blogs could have been written by even me as I had enough knowledge about the tech related to it - enough to teach someone about it. Since high-school had ended, I had a lot of free time apart from just coding, thus I decided to start blogging.</p>
<h2 id="heading-implementing-the-idea">Implementing the Idea</h2>
<p>Blogging nowadays has been made a lot lot lot more easier than it used to be earlier. There are a lot of apps which let you create a blogging account where you can post your blogs and you get free SEO and views as it’s more of a community rather than being just an app where lakhs of people browse through the blogs posted on the app. If I were to name a few of them they would be <a target="_blank" href="https://hashnode.com">HashNode</a>, <a target="_blank" href="https://dev.to">Dev.to</a>, <a target="_blank" href="https://substack.com">SubStack</a> and even <a target="_blank" href="https://medium.com">Medium</a>. For me, I used to use Dev.to and HashNode myself for reading blogs and was aware of the SEO and reach they provided as I had seen a lot of Dev.to and HashNode blogs pop up on my google feed! </p>
<p>I decided to start with Dev.to. I wrote my very first technical blog on April 11th, 2022 which was about a web app which lets you copy paste pre built box shadows for CSS. I wrote a concise post about it but sadly it didn’t get much attention from the community which made me doubt whether I was doing it correctly. I took a break, read more blogs and found out that blogs that tend to be more engaging tend to get more attention from the community. Following that I wrote one more blog (not a blog but kind of a discussion) about which JavaScript frameworks others were using, and to my surprise it got more attention and quite a few people also commented talking about their frameworks. I wrote 4 more discussion related blogs in May 2022 and my blog engagement kept increasing until one of the blogs blew up with more than 16k views as of now with 374 reactions and 188 comments on Dev.to!</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5sm4w8yb18no9a0v7ia1.png" alt="devstats" /></p>
<p>Till June 2022, I kept on writing more blogs covering different topics like list of resources for developers, some tutorials, and blogs about new tech like JavaScript frameworks. Since then, my engagement on articles has been steadily increasing and currently I have almost 800 followers on <a target="_blank" href="http://Dev.to">Dev.to</a> which took me just 3 months to achieve!</p>
<h2 id="heading-how-blogging-helped-me">How Blogging helped me</h2>
<p>The first and the most important thing that I gained from blogging was more knowledge and the ability to do research on tech. Sometimes I would just sit and learn about something till I was confident enough to write about it in my blogs which eventually made me a better developer and a better writer. It was like <em>hitting two birds with the same arrow</em>. </p>
<p>The second thing that I learnt from blogging was optimism and taking criticism in a good way. It doesn’t matter how many followers I have as I’m still very new to content writing. So, often I would end up writing things that were inappropriate which would end up with others pointing them out which is obviously a good thing but some of them used to be too harsh or rude. At first, it used to make me sad but then eventually I learnt how to take those comments as feedbacks rather than taking them as insults and working on those “feedbacks” improved my writing a lot.</p>
<p>The third thing that I got by blogging was exposure in the tech community. A lot of my blogs were actually featured on some newsletters and posted on twitter which ended up with me getting to know a lot of like minded people. Though I’m not known enough on twitter as I don’t post regularly there.</p>
<p>The last but not the least thing that I gained by blogging regularly is getting a part time technical writing job. I’ll write about it in the next section as it’s going to be a bit longer.</p>
<h2 id="heading-getting-a-part-time-job">Getting a part time job</h2>
<p>By July 2022, I was somewhat confident in what I was writing after working on my articles based on the feedbacks. Soon, I learnt that technical writing can be monetized and can be turned into a paid opportunity. Being a student, it sometimes gets difficult for me to afford things I need, to continue working on things I love to as I don’t want to burden my parents with that. Thus I decided to monetize my articles. </p>
<p>Now I had two ways of monetizing them, first - find sponsors for my blog and write a bit about them in my blogs to get paid and the second - apply for a part time technical writing position. To be honest, the first one is more difficult as I’m still not famous enough to get good sponsors, so I decided to go with the second one.</p>
<p>The first technical writing job I applied for was from <a target="_blank" href="https://kinsta.com">Kinsta</a> and it was posted on <a target="_blank" href="http://Dev.to">Dev.to</a> job listings so finding it wasn’t that hard. I mailed them about my Dev.to profile and samples of my writing and my tech stack. Surprisingly enough, I got accepted as a freelance writer for them with a decent pay per article for a beginner. My first article for Kinsta is still under review and would be posted soon hopefully. Then, around July end, <a target="_blank" href="https://scrimba.com">Scrimba</a> posted an announcement that they want <a target="_blank" href="https://community-handbook.scrimba.com/write-for-scrimba">freelance writers to write for them</a>. I was very excited to apply for it as the benefits and payout were just amazing. I filled out the application form with my writing samples, article suggestions , GitHub profile, and my experience. I knew it wasn’t going to be easy to get this job as there were a lot of people applying for it. </p>
<p>But but but - I made it! I received a mail about their interest in my writings and that they wanted to work with me! I was overwhelmed and got on board in just a few days and started writing my first article - <a target="_blank" href="https://scrimba.com/articles/create-react-app-with-vite/">Create a new React app with Vite</a>. It got posted on Scrimba and my Dev.to and HashNode profiles few days back and has been getting a lot of engagement and attention from the tech community. It even got featured on some newsletters and got a lot of twitter shout-outs.</p>
<h2 id="heading-what-it-took-to-get-the-job">What it took to get the job</h2>
<p>As easy as getting a part time job in tech may sound in this blog, I would only say - “it’s not and it’s definitely not.”. Nothing can be achieved without you trying hard and working hard to achieve it. First of all, getting a paid opportunity is never all about getting paid, as a beginner your first priority should be getting the experience of working professionally, don't hesitate to take voluntary jobs as long as they help you gain something which would help you later with a paid opportunity. </p>
<p>Apart from thus there are a few things which are a must if you're trying to find a job in tech -</p>
<ol>
<li>Know your stack - It doesn't matter what tech stack you use, make sure you are comfortable with each of them, comfortable enough to teach someone the basics of it. </li>
<li>Apply your knowledge - As long as you don't actually build something, there's literally no way for others to know that you're actually good with it. Make projects and showcase them. </li>
<li>GitHub is important - This is something which to be honest is not focused on much by beginners. But GitHub has played the most important role in helping me get a job. Not only does GitHub provide you a way to keep track of your projects, its the very proof that you actually know your tech stack. </li>
</ol>
<p>These are the most important tips you should actually work on if you're serious about getting a job in tech. There are a few more which are quite important as well like having a resume or a LinkedIn account but in my case these were not needed at any stage of getting work as my GitHub account is the ultimate proof of my experience and tech stack.</p>
<p>Nevertheless, the most important part is to believe in yourself and what you are doing. Make long term goals and believe that you can achieve them. Short term goals always tend to be not completed due to things like procrastination and burn outs.</p>
<h2 id="heading-the-verdict">The Verdict</h2>
<p>The one single thing that played the most important role in me landing a job for me was of course the fact that I decided to start blogging. Back then, if I hadn’t started blogging, I don’t think I would have known the tech related to web development so fast and gain all this work experience. I’m not saying that blogging is what you should do too to land a job, content writing is not everyone’s cup of tea. But there are a lot of other things which you can work on to get a job in tech. Just make sure you give your best in that.</p>
<p>I tried to keep the blog as concise and to the point as possible and I hope it would be helpful for people looking to get a job in tech. Thanks f</p>
]]></content:encoded></item><item><title><![CDATA[Create a new React app with Vite]]></title><description><![CDATA[Although every React app is unique, they all start from the same place:

You need an index.js, App.js, and App.css file
You need to install react and react-dom
You need a toolchain to use JSX
You need a bundler to bundle all your .js, .css, etc. file...]]></description><link>https://h.asrvd.me/create-a-new-react-app-with-vite</link><guid isPermaLink="true">https://h.asrvd.me/create-a-new-react-app-with-vite</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[React]]></category><category><![CDATA[vite]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[ashish]]></dc:creator><pubDate>Fri, 19 Aug 2022 02:40:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1660793434687/XPgTwNuKZ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Although every React app is unique, they all start from the same place:</p>
<ul>
<li>You need an index.js, App.js, and App.css file</li>
<li>You need to install react and react-dom</li>
<li>You need a toolchain to use JSX</li>
<li>You need a bundler to bundle all your .js, .css, etc. files into one easy-to-deploy file</li>
</ul>
<p>This foundation is essential!</p>
<p>… But it’s also monotonous to set up for every project.</p>
<p>I’m sure you’d rather spend time on the features unique to your app and Vite can help!</p>
<p>Vite (pronounced “veet” and French for “quick” 👀) makes you more productive.</p>
<p>With one command and a few seconds, it can generate all the above boilerplate for you and more!</p>
<p>Additionally, Vite:</p>
<ul>
<li>Enables Hot Module Replacement (HMR), as seen in the animation below</li>
<li>Makes it easy to deploy your website to the internet</li>
<li>Helps you import and manage (potentially sensitive) environment variables</li>
<li>Makes it easy to bolt-on technologies you need, for example, TypeScript</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1660876457339/575KLHZPE.gif" alt="GIF showing Vite HMR in action" /></p>
<p>Needless to say this is something you need in your arsenal of developer tutorials!</p>
<p>In this tutorial, I will show you step by step:</p>
<ul>
<li>How to scaffold your React app with Vite</li>
<li>How to enable HMR, as seen above</li>
<li>You will learn how to deploy your app easily to Netlify</li>
</ul>
<p>To wrap up this ✨ ultimate ✨ post, I’ll give a whistle-stop tour of some advanced Vite features.</p>
<h2 id="heading-what-is-the-difference-between-vite-and-create-react-app">What is the difference between Vite and Create React App?</h2>
<p>If you've been around the React ecosystem for a minute, you will likely recognize Create React App (CRA), which, on the surface, sounds very similar to Vite.</p>
<p>Since CRA is made and maintained by React themselves, it's natural to wonder how these two tools compare.</p>
<h3 id="heading-cra">CRA</h3>
<p>Around seven years ago, React designed and released CRA to help newer developers adopt React more easily.</p>
<p>In particular, React acknowledged that to use JSX, you need some toolchain, and that made React's learning curve much steeper compared to, for example, Vue, where you don't need a build tool.</p>
<p>More experienced React developers use and appreciate CRA as well. Although, they sometimes need to use something else once their projects become more complex.</p>
<h3 id="heading-vite">Vite</h3>
<p>The web has fundamentally evolved in the 7 years since CRA was designed.</p>
<p>According to the Vite documentation, "as we build more and more ambitious applications, the amount of JavaScript we are dealing with is also increasing dramatically. It is not uncommon for large-scale projects to contain thousands of modules."</p>
<p>Because the dependencies to make a React app have become so large and interconnected, tools like CRA can sometimes take an unreasonably long wait (sometimes up to minutes!) to start up, and changes can take a couple of seconds to be reflected in the browser.</p>
<p>Vite points out, "The slow feedback loop can greatly affect developers' productivity and happiness."</p>
<p>In summary, React apps are becoming more complex, demanding more from our tools. Simultaneously, web browsers are evolving. For example, the latest browsers now support importing modules directly.</p>
<p>We can only benefit from these advancements if our tools are updated.</p>
<p>That is where Vite comes in.</p>
<p>Vite aims to leverage advancements in the ecosystem. Not only to make load times quicker but also to offer an instantaneous, almost magic-feeling developer experience as you saw in the HMR video above.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.youtube.com/watch?v=QtdznSAxdCU">https://www.youtube.com/watch?v=QtdznSAxdCU</a></div>
<p>Unlike Create React App, Vite is not inherently coupled with React. You could use Vite with Vue, for example!</p>
<p>While you might not plan to use another frontend library any time soon, open source maintainers banding together across the ecosystem will benefit you as more features make their way to releases and bugs are squashed more quickly.</p>
<h2 id="heading-getting-started-with-vite">Getting Started With Vite</h2>
<p>Alright, now you know all about Vite (and how it compares to CRA), let's get hands-on.</p>
<p>In this section, I encourage you to follow along as we install Vite and set up a React project in no time.</p>
<blockquote>
<p><strong>What do I need to know?</strong> To follow along, you will need to have npm installed. It would be good if you were already familiar with npm and command-line programs, but it's not a requirement!</p>
</blockquote>
<h3 id="heading-how-to-run-vite">How to run Vite</h3>
<p>The official way to run Vite is using the npm create command. Open your terminal of choice, copy, then run the following command:</p>
<pre><code class="lang-bash">npm create vite@latest
</code></pre>
<p>Vite makes life easy by prompting you with questions.</p>
<p>First, Vite asks for your project name.</p>
<p>Then, Vite will want to know if you’re using React or another library (remember, Vite is not limited to React.)</p>
<p>Here, I called my project vite-app and chose react:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byi38q5lfbgajj54kuh0.png" alt="vite-terminal-1" /></p>
<p>True to its name, Vite will quickly generate all the scaffolding for your project and some handy scripts to enable HMR.</p>
<p>Once the command has finished running, cd into your folder and run the following commands:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> vite-app <span class="hljs-comment"># Vite made a new folder named after your project</span>
npm install
npm run dev
</code></pre>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04fxqksk8d9e8lrs6qra.png" alt="vite-terminal-2" /></p>
<p>Since both <code>npm create</code> and <code>npm install</code> depend on your internet connection, they may take a minute or two to run.</p>
<p>Once everything is set up, look how quickly Vite served the app - just 5 seconds! That’s the magic of Vite.</p>
<p>Next, open <a target="_blank" href="https://localhost:5173">localhost:5173</a> in your browser. You will see Vite's default template:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ksixquzucs2yfbatdg7g.png" alt="vite-react-app" /></p>
<p>Of course you want to make some updates. Why not take advantage of HMR in the process?</p>
<h2 id="heading-what-is-hmr">What is HMR?</h2>
<p>In the past, whenever you would make a change to your code - no matter how small - you would need to rebuild the entire app and refresh the page.</p>
<p>Rebuilding the entire app for one small change is slow.</p>
<p>Refreshing the browser isn't so bad, but you lose all the values in your variables (otherwise known as state) every time you do that.</p>
<p>Sometimes this is desirable, but it would be better if only the presentation parts changed when it comes to tweaking or iterating on your app (especially the style).</p>
<p>Enter HMR!</p>
<p>HMR intelligently rebuilds and reloads only the parts of your app that <strong>actually</strong> changed. It’s fast, and you keep your application state if you want.</p>
<p>HMR saves time you would otherwise spend waiting around or inputting data to recreate your application state. More than that, it reduces friction, allowing you to stay focused on your task and be more productive.</p>
<h2 id="heading-test-vite-hmr">Test Vite HMR</h2>
<p>Let’s take Vite’s built-in HMR for a spin.</p>
<ol>
<li>Open src/App.js in your editor</li>
<li>Open  <a target="_blank" href="https://localhost:5173">localhost:5173</a> (ideally on the other side of your screen to observe the effect)</li>
<li>Increment the counter</li>
<li>Remove lines 10-17 from src/App.js (basically removing the two logos from the app)</li>
</ol>
<p>If you opened your windows side by side, you should observe the following:</p>
<p>In my case, I increment the counter to 12 before removing the logos.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1660876673083/5dX8AY5eR.gif" alt="demo of Vite HMR" /></p>
<p>Usually, the page would reload, and the counter would be reduced to its default value of 0. HMR worked its magic behind the scenes to only change the part of the page that actually changed in the code.</p>
<h2 id="heading-deploying-your-app-to-production">Deploying your app to production</h2>
<p>Vite makes it approachable to deploy your React website to Vercel, GitHub pages, or <a target="_blank" href="https://netlify.com">Netlify</a>.</p>
<p>So approachable, I am encouraging you to follow along as we deploy the generated application to Netlify. When you make changes, updating the live website will be much easier then.</p>
<blockquote>
<p>What do I need to know? To follow along, you will need: A GitHub account, Git installed locally, and <a target="_blank" href="https://scrimba.com/playlist/pYLnBT4">fundamental knowledge of Git</a>.</p>
</blockquote>
<h3 id="heading-start-with-git">Start with Git</h3>
<p>Nowadays, a practice called continuous deployment is common and encouraged.</p>
<p>In simple terms, when you push your code to the main branch on GitHub, services like Netlify detect this, download your updates, and update your live website. Vite can help accommodate this.</p>
<p>That might sound a bit mind-bending so I encourage you to try it for yourself. It’ll be much easier to understand when you see it all in action.</p>
<p>First up, create a GitHub repository and note the URL.</p>
<p>Next, run the following commands (making sure to replace  with your repository URL!):</p>
<pre><code class="lang-bash">git init
git add .
git commit -m <span class="hljs-string">"Initial commit"</span>
git branch -M main
git remote add origin &lt;your_github_repository_url_goes_here&gt;
git push -u origin main
</code></pre>
<h3 id="heading-import-project-in-netlify">Import project in Netlify</h3>
<p>Great! You’ve made a GitHub repository and uploaded the code Vite generated there.</p>
<p>Next, we’ll let Netlify know about the GitHub repository.</p>
<p>If you haven’t already, this is a good time to <a target="_blank" href="https://app.netlify.com/signup">make a free Netlify account</a>.</p>
<p>Once you’ve logged in, click <strong>Add New Site</strong>, then <strong>Import Existing Project</strong>.</p>
<p>You will see the following page:</p>
<p>!netlify-1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45vikqcn6d9rjbph7zgi.png)</p>
<p>Click <strong>GitHub</strong>.</p>
<p>GitHub will ask if you want to give Netlify permissions to see your repositories and download them. You can go ahead!</p>
<p>Once Netlify has permission to interact with your GitHub account, it will load and list all your repositories. Pick the repository you just created. As you may recall, mine is called vite-app:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jygyclia4wj77odyfa5g.png" alt="netlify-2" /></p>
<h3 id="heading-deploy-your-app">Deploy your app</h3>
<p>Once you select your repository, you’ll be prompted to set some settings. Vite knows what Netlify wants to see and make your life easy by adhering tot he defaults. That means you don’t have to change anything here. Just hit <strong>Deploy site</strong>:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s03yyl1wmdecn2gqrl8p.png" alt="netlify-3" /></p>
<p>Once deployed, you should see this page and the link to your website:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5584sv9bdtebmq70yon.png" alt="netlify-4" /></p>
<p>In our case, the link is <a target="_blank" href="https://resilient-gaufre-20030a.netlify.app/">resilient-gaufre-20030a.netlify.app</a>:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oog4slxqw4h86153zm5w.png" alt="netlify-prod-app" /></p>
<p>When you next have some free time, poke around the <strong>Site Settings</strong>.</p>
<p>Here, you can change everything related to your site and even assign a custom domain name!</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ox0nd6vzrne4xx2cipv5.png" alt="netlify-5" /></p>
<p>As you make changes to your code and push them to GitHub, Netlify should detect this and update the live site!</p>
<p>For more in-depth tutorials on deploying a Vite app to other hosting providers, you can visit Vite’s <a target="_blank" href="https://vitejs.dev/guide/static-deploy.html">deploying a site</a> section in its docs.</p>
<h2 id="heading-advanced-vite">Advanced Vite</h2>
<p>Vite is built on the shoulders of giants - namely, <a target="_blank" href="https://rollupjs.org/guide/en/">Rollup</a> and <a target="_blank" href="https://esbuild.github.io/">EsBuild</a>:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzv5yvswextccoouaunl.png" alt="vite-flowchart" /></p>
<p>Understanding how Vite works under the hood at the high level lends way to some advanced features you can take advantage of.</p>
<h3 id="heading-plugins">Plugins</h3>
<p>Vite can be extended using plugins based on Rollup's well-designed plugin interface with a few extra Vite-specific options.</p>
<p>This means that Vite users can rely on the mature ecosystem of Rollup plugins, while extending the dev server and SSR functionality as needed.</p>
<p>In short, plugins let you do <strong>more</strong> with your site app by providing integrations with other tools and adding additional features on top of Vite to make development easier.</p>
<p>Vite has a very <a target="_blank" href="https://vitejs.dev/guide/using-plugins.html">in-depth guide about plugins</a> in its docs. You can read it to get started with plugins.</p>
<h3 id="heading-env-variables">Env Variables</h3>
<p>Env Variables are the variables set outside the code itself but are very important for the code to run and can't be leaked along with your code base.</p>
<p>They can be a token from an API you are using, Auth token, Database passwords, or anything that you wouldn’t want anyone else looking at your code to discover. To set env variables, you create a <code>.env</code> file in the root of your application and then add your variables in the format <code>TOKEN=secret_token</code>, In most JavaScript applications you can access your env variables in code using the <code>process.env</code> object.</p>
<p>Vite uses the object <code>import.meta.env</code> to expose your env variables, by default the env variables are not exposed to the frontend to prevent token leaking. To expose your variables to your code, you can prefix the variable name with <code>VITE_</code>.</p>
<pre><code class="lang-bash"><span class="hljs-comment"># This will not be exposed to the frontend</span>
SECRET_TOKEN=i_should_not_be_exposed_to_the_client

<span class="hljs-comment"># This will be exposed to the frontend</span>
VITE_NORMAL_TOKEN=i_can_be_exposed_to_the_client
</code></pre>
<p>Now, to use these tokens in your code:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">import</span>.meta.env.SECRET_TOKEN)
<span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">import</span>.meta.env.VITE_NORMAL_TOKEN)
</code></pre>
<p>There are some more concepts that you may need to know if you need more functionalities in your project like <a target="_blank" href="https://vitejs.dev/guide/backend-integration.html">backend integration</a> and <a target="_blank" href="https://vitejs.dev/guide/ssr.html">server-side rendering</a> but they are out of scope for this article.</p>
<h2 id="heading-the-verdict">The Verdict</h2>
<p>According to npm, Vite is downloaded 1.4 million times a week, and that number is only going up! Perhaps now you’ve read this post, you can understand why!</p>
<p>In this post, we explored the fundamentals of Vite and how it compares to Create React App.</p>
<p>You got to experience first-hand how, when you start your project with Vite, it becomes somewhat straightforward to enable other productivity-boosting features like HMR, or even deploy your website to Netlify, for example.</p>
<p>Vite is easy because it hides a lot of the nitty-gritty details behind commands. Simultaneously, it’s still possible to drop down a level and take advantage of tried-and-true Rollup plugins. Looking back, it’s clear the Vite team observed developers in action to design and build a tool suitable for newer React developers and experts alike.</p>
]]></content:encoded></item></channel></rss>