<?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: Jeferson F Silva</title>
    <description>The latest articles on Forem by Jeferson F Silva (@jeferson0993).</description>
    <link>https://forem.com/jeferson0993</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%2F313302%2F910e5872-d4b4-4cfb-bcf1-6f68ceaac789.jpeg</url>
      <title>Forem: Jeferson F Silva</title>
      <link>https://forem.com/jeferson0993</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/jeferson0993"/>
    <language>en</language>
    <item>
      <title>I Just Launched a Meme Coin!</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Sun, 05 Jan 2025 12:53:39 +0000</pubDate>
      <link>https://forem.com/jeferson0993/i-just-launched-a-meme-coin-a71</link>
      <guid>https://forem.com/jeferson0993/i-just-launched-a-meme-coin-a71</guid>
      <description>&lt;h2&gt;
  
  
  The Birth of Dev Lol Coin
&lt;/h2&gt;

&lt;p&gt;It started as a joke. Like many developers, I’ve spent countless hours debugging code, staring at errors that make no sense, and deploying fixes at 3 AM only to find out they broke something else. Amid this chaos, I thought: &lt;em&gt;What if we could immortalize this hilarity on the blockchain?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Enter &lt;strong&gt;Dev Lol Coin ($LOLDEV)&lt;/strong&gt;. It’s a satirical meme coin designed to celebrate (or mock) the trials and tribulations of developers worldwide. Built on the Solana blockchain, $LOLDEV is fast, absurd, and unapologetically ridiculous—just like the dev life.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;a href="https://pump.fun/coin/378jHA9sF9z4UNZzT64PkdN8EgjTTtDorY35zTBGpump" rel="noopener noreferrer"&gt;Buy the $LOLDEV token here with your phantom wallet&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Why Launch a Meme Coin?
&lt;/h2&gt;

&lt;p&gt;Meme coins are the ultimate internet inside joke. They’re born out of cultural moments, shared frustrations, or just sheer randomness. For me, $LOLDEV is a way to capture the developer’s experience: the bugs, the builds, and the occasional breakthrough.&lt;/p&gt;

&lt;p&gt;Plus, why not? If Dogecoin can take us to the moon, maybe $LOLDEV can take us to… the next successful CI/CD pipeline?&lt;/p&gt;




&lt;h2&gt;
  
  
  How I Built It
&lt;/h2&gt;

&lt;p&gt;Creating a token on Solana is surprisingly straightforward (at least for devs who have been knee-deep in documentation before). Here’s a quick breakdown of how $LOLDEV came to life:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Choosing the Blockchain:&lt;/strong&gt; Solana was a no-brainer. It’s fast, has low fees, and offers robust developer tools. Perfect for a meme coin that needs to move as quickly as developers pushing a hotfix.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Developing the Token:&lt;/strong&gt; Using the Solana CLI and the SPL Token program, I generated $LOLDEV with a fixed supply to keep it simple.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Creating the Ticker:&lt;/strong&gt; $LOLDEV. Short, sweet, and packed with irony.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Minting the Coin:&lt;/strong&gt; I minted an initial supply of $1,000,000,000 LOLDEV tokens. Because why stop at millions when you can have billions?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Designing the Branding:&lt;/strong&gt; A meme coin needs memes. I’ve put together a collection of developer-themed memes to promote $LOLDEV across social media. "&lt;em&gt;Error 404: Serious Investment Not Found.&lt;/em&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  What’s Next for $LOLDEV?
&lt;/h2&gt;

&lt;p&gt;Right now, $LOLDEV is just for fun. I’ve airdropped some to fellow developers and friends who share my sense of humor. Here’s what I’m planning next:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A Meme Marketplace:&lt;/strong&gt; A platform where $LOLDEV can be used to buy, sell, and trade developer-themed memes and NFTs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Community Engagement:&lt;/strong&gt; Hosting meme competitions and dev challenges, with $LOLDEV as rewards.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;More Laughs:&lt;/strong&gt; Turning $LOLDEV into a symbol of solidarity for devs. Because if we can’t laugh at our bugs, what can we do?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;Launching a meme coin taught me a lot about blockchain, community building, and the power of humor in tech. But more importantly, it reminded me that the best projects often start with a simple idea: &lt;em&gt;Let’s have some fun.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So here’s to $LOLDEV, the meme coin for anyone who’s ever yelled "&lt;em&gt;It works on my machine!&lt;/em&gt;" Cheers to the devs, the memes, and the madness.&lt;/p&gt;

&lt;p&gt;Let’s see where this ride takes us.&lt;/p&gt;




&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my portfolio &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

</description>
      <category>loldev</category>
      <category>solana</category>
    </item>
    <item>
      <title>Why Monorepo Projects Sucks: Performance Considerations with Nx</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Wed, 11 Dec 2024 00:17:40 +0000</pubDate>
      <link>https://forem.com/jeferson0993/why-monorepo-projects-sucks-performance-considerations-with-nx-2mnk</link>
      <guid>https://forem.com/jeferson0993/why-monorepo-projects-sucks-performance-considerations-with-nx-2mnk</guid>
      <description>&lt;p&gt;In the world of software development, monorepo setups have become a popular trend, especially with tools like Nx that promise better integration, faster builds, and more efficient workflows. A monorepo is where multiple projects, often microservices or libraries, live in a single repository. Sounds convenient, right? One repo to rule them all! But not so fast — while the monorepo approach might shine in some cases, it’s not always the best solution, especially when performance is a key concern.&lt;/p&gt;

&lt;p&gt;Let's dive into some of the key performance issues with monorepo projects, and why Nx, despite its benefits, may not always be the silver bullet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Longer Build Times for Large Projects
&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%2Fwypmhqj4e76kpmtefuxk.gif" 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%2Fwypmhqj4e76kpmtefuxk.gif" alt="Mr Bean waiting" width="640" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Monorepos are supposed to streamline things by centralizing code, but as the number of projects grows, so do build times. Even though Nx is optimized to run tasks efficiently, a monorepo with hundreds of libraries or services means that dependency graphs can get extremely large. When a change is made, Nx needs to analyze dependencies and determine what needs to be rebuilt. In some cases, this process can get complex and slow.&lt;/p&gt;

&lt;p&gt;Imagine that a tiny bug fix in a small library requires building a significant portion of the repo. This overhead can result in frustratingly long build times, killing developer productivity and increasing CI pipeline duration. In contrast, a polyrepo approach (where each project lives in its own repository) may allow independent builds, reducing the scope of what needs to be compiled and tested.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overhead with Task Scheduling
&lt;/h2&gt;

&lt;p&gt;Nx introduces task scheduling to optimize parallel builds and test runs. However, this scheduling system adds a layer of complexity. As the number of developers and commits grows, task execution can become bottlenecked. Nx does a good job of managing this, but in large monorepos, the overhead of orchestrating hundreds or thousands of tasks becomes inefficient.&lt;/p&gt;

&lt;p&gt;Moreover, Nx’s caching mechanism, designed to speed up builds by reusing previous results, can sometimes lead to cache misses due to small changes, forcing a rebuild of many unrelated parts of the repo. This negates the caching benefits and causes slowdowns, which can be especially problematic in CI environments where time is crucial.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependency Bloat and Codebase Size
&lt;/h2&gt;

&lt;p&gt;don’t actually need for a specific service or library but are kept for “convenience.” This leads to increased disk usage, slower git operations, and more complicated dependency management.&lt;/p&gt;

&lt;p&gt;Over time, this leads to situations where developers are dealing with dependency hell. Updating shared libraries or dependencies becomes a monumental task, as every project in the monorepo must be considered. This can create a ripple effect, leading to longer build times, merge conflicts, and higher risk of bugs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scaling Development Teams
&lt;/h2&gt;

&lt;p&gt;In smaller teams or projects, a monorepo with Nx might work fine. But as your team scales, so do the issues. With a monorepo, you are essentially coupling everything together. Even though teams may work on different parts of the codebase, they are still impacted by changes in other parts of the repo. This increases the coordination overhead, slowing down development and causing friction between teams.&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%2Fmadw67rgsezar40abmdo.gif" 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%2Fmadw67rgsezar40abmdo.gif" alt="spogebong patrick" width="320" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A polyrepo setup allows teams to work more independently, with fewer merge conflicts and less coordination. When you have multiple teams contributing to a single monorepo, the velocity of development can decrease due to these conflicts, hurting overall productivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI/CD Pipeline Bottlenecks
&lt;/h2&gt;

&lt;p&gt;CI/CD pipelines in monorepos can become a nightmare. Despite Nx’s ability to run only affected projects, changes in shared libraries or configurations can still trigger the build and test of a large number of projects. The more services or libraries you have in a single repo, the more your pipeline becomes clogged with tasks. Nx’s distributed caching can help alleviate some of this, but it's not a perfect solution, especially in a fast-paced environment where small changes can trigger large rebuilds.&lt;/p&gt;

&lt;p&gt;In contrast, in a polyrepo setup, the CI/CD pipeline can be much more granular, running builds and tests only for the specific project where the changes were made. This localized pipeline approach can result in faster deployments and quicker feedback.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: Is Nx Always the Best Solution?
&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%2Fuqhk56na9c9c63dla1a6.gif" 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%2Fuqhk56na9c9c63dla1a6.gif" alt="thumbsdown" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While Nx and the monorepo approach offer some significant benefits, such as code sharing and streamlined tooling, they can introduce serious performance bottlenecks for large, complex codebases. Build times, task scheduling overhead, dependency bloat, and scaling issues are all valid reasons why monorepos might not be the best fit in certain scenarios.&lt;/p&gt;

&lt;p&gt;For smaller projects, or tightly integrated systems, a monorepo can be highly effective. But as your codebase and teams grow, you might find that the performance penalties outweigh the benefits. In those cases, it’s worth considering a polyrepo setup, or at least weighing the trade-offs before fully committing to Nx and monorepos.&lt;/p&gt;

&lt;p&gt;Ultimately, the right approach depends on the size of your project, team structure, and performance needs. Monorepos aren’t a one-size-fits-all solution — and sometimes, they suck.&lt;/p&gt;

&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;portfolio here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>devops</category>
      <category>productivity</category>
      <category>nx</category>
    </item>
    <item>
      <title>How to Optimize a Website for Search Engines: A Comprehensive Guide</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Wed, 20 Nov 2024 16:33:25 +0000</pubDate>
      <link>https://forem.com/jeferson0993/how-to-optimize-a-website-for-search-engines-a-comprehensive-guide-23op</link>
      <guid>https://forem.com/jeferson0993/how-to-optimize-a-website-for-search-engines-a-comprehensive-guide-23op</guid>
      <description>&lt;p&gt;Optimizing a website for search engines like google and yahoo, usually called search engine marketing (Search Engine Optimization), is vital for enhancing visibility, riding organic visitors, and improving rankings on seek engine result pages (SERPs). Below is a step-with the aid of-step manual to help you acquire effective SEO to your website.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;strong&gt;Conduct Keyword Research&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why it Matters&lt;/strong&gt;: Keywords are the foundation of search engine optimization. Understanding what phrases users search for can help you goal their desires.&lt;/p&gt;

&lt;p&gt;👣 &lt;strong&gt;Steps&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use equipment like Google Keyword Planner, Ahrefs, or SEMrush to find relevant key phrases.&lt;/li&gt;
&lt;li&gt;Identify &lt;strong&gt;number one key phrases&lt;/strong&gt; (excessive-volume, high-relevance) and &lt;strong&gt;long-tail key phrases&lt;/strong&gt; (low-extent, high-specificity).&lt;/li&gt;
&lt;li&gt;Analyze competitor web sites for keyword opportunities.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Pro Tips&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prioritize keywords with excessive search volume but mild competition.&lt;/li&gt;
&lt;li&gt;Consider consumer reason behind each key-word: informational, navigational, or transactional.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. &lt;strong&gt;Optimize On-Page search engine optimization Elements&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Key Elements to Focus On&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Title Tags&lt;/strong&gt;: Include number one keywords and restriction titles to 60 characters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Meta Descriptions&lt;/strong&gt;: Summarize the content compellingly at the same time as such as keywords.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Headings (H1, H2, H3)&lt;/strong&gt;: Use clean, keyword-optimized headings to shape your content material.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;URL Structure&lt;/strong&gt;: Keep URLs short, descriptive, and key-word-rich.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Image Alt Text&lt;/strong&gt;: Add descriptive text to all snap shots for accessibility and search engine optimization.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
Instead of: &lt;code&gt;www.Instance.Com/p123&lt;/code&gt;&lt;br&gt;
Use: &lt;code&gt;www.Example.Com/search-engine-optimization-guide&lt;/code&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3. &lt;strong&gt;Create High-Quality Content&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Content Strategies&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write particular, in-intensity articles tailored in your target audience's wishes.&lt;/li&gt;
&lt;li&gt;Incorporate keywords obviously to keep away from overstuffing.&lt;/li&gt;
&lt;li&gt;Include &lt;strong&gt;visual content&lt;/strong&gt; including photographs, infographics, and films to decorate engagement.&lt;/li&gt;
&lt;li&gt;Regularly update antique content material to keep it applicable and sparkling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Pro Tips&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Aim for a readability rating appropriate in your target audience.&lt;/li&gt;
&lt;li&gt;Use internal links to guide users to related pages in your internet site.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  four. &lt;strong&gt;Improve Technical search engine optimization&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Technical search engine optimization Components&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Site Speed&lt;/strong&gt;: Ensure your website loads inside 2–three seconds using equipment like Google PageSpeed Insights.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mobile-Friendliness&lt;/strong&gt;: Implement responsive design to make sure compatibility with all gadgets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Crawlability&lt;/strong&gt;: Submit a sitemap to engines like google to make your site simpler to index.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secure Protocols&lt;/strong&gt;: Use HTTPS instead of HTTP to secure consumer statistics and construct believe.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Pro Tips&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fix broken hyperlinks to beautify the user revel in.&lt;/li&gt;
&lt;li&gt;Use based data (schema markup) to help search engines like google and yahoo understand your content.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  5. &lt;strong&gt;Leverage Off-Page search engine marketing&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Tactics&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backlink Building&lt;/strong&gt;: Earn top notch backlinks from authoritative websites via guest running a blog, outreach, or partnerships.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Social Media&lt;/strong&gt;: Share your content throughout platforms to increase visibility and generate referral traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Online Directories&lt;/strong&gt;: Ensure your website is listed in relevant directories with steady records.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Pro Tips&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Focus on exceptional over amount for one way links.&lt;/li&gt;
&lt;li&gt;Engage in on line groups to construct relationships and credibility.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  6. &lt;strong&gt;Monitor and Analyze Performance&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;🛠️&lt;strong&gt;Tools&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Google Analytics&lt;/strong&gt;: Track traffic resources, user conduct, and conversions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Google Search Console&lt;/strong&gt;: Identify technical troubles and display key-word performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;search engine marketing Tools&lt;/strong&gt;: Use structures like Ahrefs, Moz, or SEMrush to research scores and oneway links.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Pro Tips&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set benchmarks to degree the achievement of your optimization efforts.&lt;/li&gt;
&lt;li&gt;Perform ordinary search engine marketing audits to discover new opportunities and problems.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  7. &lt;strong&gt;Local search engine optimization (If Applicable)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;👣 &lt;strong&gt;Steps&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Claim your Google Business Profile and make certain accurate records.&lt;/li&gt;
&lt;li&gt;Include nearby keywords on your content material.&lt;/li&gt;
&lt;li&gt;Encourage satisfied customers to depart reviews on platforms like Google or Yelp.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ &lt;strong&gt;Pro Tips&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Embed Google Maps for nearby agencies.&lt;/li&gt;
&lt;li&gt;Use place-specific landing pages if serving a couple of areas.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  8. &lt;strong&gt;Maintain an search engine marketing-First Mindset&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why It Matters&lt;/strong&gt;:&lt;br&gt;
search engine optimization isn't always a one-time interest. Consistency and adaptability are crucial as search engines like google and yahoo update their algorithms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Regular Practices&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Publish new content regularly.&lt;/li&gt;
&lt;li&gt;Monitor competitor techniques and adapt as a consequence.&lt;/li&gt;
&lt;li&gt;Stay up to date on search engine optimization developments and algorithm adjustments.&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Optimizing a website for serps requires a combination of strategic planning, technical talent, and consistent attempt. By following the steps outlined above, you can decorate your web page's visibility, attract more visitors, and gain your commercial enterprise goals.&lt;/p&gt;




&lt;h3&gt;
  
  
  Relevant Image Concepts:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Keyword Research Visualization&lt;/strong&gt;: A chart or tool interface displaying keyword facts like search volume and opposition.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;On-Page search engine optimization Elements&lt;/strong&gt;: An infographic highlighting the name tag, meta description, and URL structure on a webpage.
Three. &lt;strong&gt;Content Optimization Workflow&lt;/strong&gt;: A step-by-step visual guide to creating search engine marketing-friendly content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical SEO Checklist&lt;/strong&gt;: A diagram showing key factors like web page velocity, cellular optimization, and HTTPS.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Tracking Dashboard&lt;/strong&gt;: A graphical depiction of analytics information for monitoring search engine optimization fulfillment.&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my portfolio &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

</description>
      <category>seo</category>
      <category>webdev</category>
      <category>performance</category>
    </item>
    <item>
      <title>Mastering the Top 4 JavaScript Frameworks: My Epic Journey</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Tue, 05 Nov 2024 13:36:22 +0000</pubDate>
      <link>https://forem.com/jeferson0993/mastering-the-top-4-javascript-frameworks-my-epic-journey-4ndf</link>
      <guid>https://forem.com/jeferson0993/mastering-the-top-4-javascript-frameworks-my-epic-journey-4ndf</guid>
      <description>&lt;p&gt;Are you ready to join me on an exciting adventure through the world of JavaScript frameworks? In this series, I'll share my hands-on experience building a real-world project with each of the top 4 frameworks: React, Vue, Angular, and Svelte.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this journey?
&lt;/h3&gt;

&lt;p&gt;As a developer, staying up-to-date with the latest frameworks and technologies is crucial. With so many options, choosing the right one for your project can be daunting. By mastering these four frameworks, you'll gain a deeper understanding of their strengths, weaknesses, and use cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Project: Social Blog app
&lt;/h3&gt;

&lt;p&gt;Throughout this series, we'll build a feature-rich blog app with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User authentication&lt;/li&gt;
&lt;li&gt;Post creation, reading, updating, and deletion (CRUD)&lt;/li&gt;
&lt;li&gt;Commenting on posts&lt;/li&gt;
&lt;li&gt;Author following&lt;/li&gt;
&lt;li&gt;And more!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's Get Started!&lt;/p&gt;

&lt;p&gt;To begin, we'll create a new project for each framework using the following CLI commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm create vite devflow-react &lt;span class="nt"&gt;--template&lt;/span&gt; react-ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Vue
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm create vite devflow-vue &lt;span class="nt"&gt;--template&lt;/span&gt; vue-ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Angular
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx &lt;span class="nt"&gt;-p&lt;/span&gt; @angular/cli@latest ng new devflow-angular &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--package-manager&lt;/span&gt; pnpm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Svelte
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm create vite devflow-svelte &lt;span class="nt"&gt;--template&lt;/span&gt; svelte-ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands will set up the basic project structure and dependencies for each framework. Note that I'm trying to maintain a standard. I'll use the same package-management for all projects, as well as try to use the same libraries as much as possible. Such as tailwindcss, prettier and eslint.&lt;/p&gt;

&lt;h3&gt;
  
  
  configuring esling, prettier and tailwindcss
&lt;/h3&gt;

&lt;p&gt;To ensure beautiful and clean code, in addition to following good development practices, it is essential to install and configure eslint and prettier in our projects. I will do this in each of them. Also, I'll use the tailwindcss to style.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing the dependencies
&lt;/h3&gt;

&lt;p&gt;React, Vue, Angular and Svelte:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm add &lt;span class="nt"&gt;-D&lt;/span&gt; eslint eslint-config-prettier &lt;span class="se"&gt;\&lt;/span&gt;
globals typescript-eslint prettier &lt;span class="se"&gt;\&lt;/span&gt;
prettier-plugin-tailwindcss tailwindcss &lt;span class="se"&gt;\&lt;/span&gt;
postcss autoprefixer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  configuring eslint
&lt;/h3&gt;

&lt;p&gt;Vue and Svelte:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm create @eslint/config@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx &lt;span class="nt"&gt;-p&lt;/span&gt; @angular/cli@latest ng lint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: React and Svelte already have eslint configured&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  configuring prettier
&lt;/h3&gt;

&lt;p&gt;Create a &lt;code&gt;.prettierrc&lt;/code&gt; file and add the following&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;"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;"bracketSpacing"&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;"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;120&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;Create a file named &lt;code&gt;.prettierignore&lt;/code&gt; in the root of the project. Add files or folders to be ignored, for example: &lt;code&gt;./node_modules/&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  configuring tailwindcss
&lt;/h3&gt;

&lt;p&gt;React, Vue and Svelte:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;generating &lt;code&gt;tailwind.config.js&lt;/code&gt; and &lt;code&gt;postcss.config.js&lt;/code&gt; files.
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Configuring the template paths: Adding the paths to all the templates files in the tailwind.config.js file.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;
  &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./index.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/**/*.{vue,js,ts,jsx,tsx}&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="cm"&gt;/* ... */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Configuring the template paths: Adding the paths to all the templates files in the tailwind.config.js file.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="cm"&gt;/* ... */&lt;/span&gt;
  &lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/**/*.{html,ts}&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="cm"&gt;/* ... */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Adding the Tailwind directives to your CSS: Adding the &lt;a class="mentioned-user" href="https://dev.to/tailwind"&gt;@tailwind&lt;/a&gt; directives for each of Tailwind’s layers to &lt;code&gt;./src/styles.css&lt;/code&gt; or &lt;code&gt;./src/index.css&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;React, Vue, Angular and Svelte:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  In upcoming articles, we'll dive into:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Implementing authentication and authorization&lt;/li&gt;
&lt;li&gt;Building the blog's core features and CRUDS&lt;/li&gt;
&lt;li&gt;Integrating commenting and user following&lt;/li&gt;
&lt;li&gt;Optimizing performance and deployment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Join the Journey!&lt;/p&gt;

&lt;p&gt;Follow along as I share my experiences, tips, and insights. Whether you're a beginner or seasoned developer, this series will provide valuable hands-on knowledge and comparisons between these top JavaScript frameworks.&lt;/p&gt;

&lt;p&gt;Stay tuned for the next article, where we'll start building our Blog!&lt;/p&gt;

&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my portfolio &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

</description>
      <category>react</category>
      <category>vue</category>
      <category>angular</category>
      <category>svelte</category>
    </item>
    <item>
      <title>A Handy Guide to Closed Source Licenses: Protecting Your Code Like a Pro</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Wed, 23 Oct 2024 11:52:50 +0000</pubDate>
      <link>https://forem.com/jeferson0993/a-handy-guide-to-closed-source-licenses-protecting-your-code-like-a-pro-10b3</link>
      <guid>https://forem.com/jeferson0993/a-handy-guide-to-closed-source-licenses-protecting-your-code-like-a-pro-10b3</guid>
      <description>&lt;p&gt;So, you’ve decided to keep your project behind the curtain—whether it's because you’re working on the next billion-dollar app, or you simply want to maintain control over your code. In the land of &lt;strong&gt;closed source software&lt;/strong&gt;, licenses play a crucial role in protecting your hard work. They set the boundaries on who can use your code, how they can use it, and—just as important—how they &lt;strong&gt;cannot&lt;/strong&gt; use it.&lt;/p&gt;

&lt;p&gt;This guide will walk you through the most common licenses used for closed source projects, what they cover, and why it’s essential to pick the right one. Plus, I’ll explain how licenses can save you from potential legal nightmares. Let's dive in!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;strong&gt;Proprietary License: Lock It Down&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Total control, no freebies here.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: A proprietary license is essentially a "no trespassing" sign for your code. The software remains the property of the creator or company, and the user is given very limited rights—usually to run or use the software under specific conditions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Businesses or developers who want to keep all rights to their software and only allow others to use it under strict terms.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You keep &lt;strong&gt;full ownership&lt;/strong&gt; over the code, including its distribution and use.&lt;/li&gt;
&lt;li&gt;Users can only use your software in ways that you explicitly allow, typically by purchasing a license.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Users may not like the lack of freedom and flexibility, which could be a turn-off, especially for individual consumers.&lt;/li&gt;
&lt;li&gt;Maintenance and licensing enforcement can be resource-intensive if you expect large-scale distribution.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. &lt;strong&gt;EULA (End-User License Agreement): The "You Can Use It, But…" Contract&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Here’s what you can and cannot do.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: An EULA is an agreement between the software developer and the end user. It details how the user can use the software, what’s forbidden (e.g., reverse engineering, sharing copies), and the consequences for breaking the terms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Software distributed directly to customers or businesses, especially apps or products with complex features that need some legal protections.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You can specify &lt;strong&gt;exactly how&lt;/strong&gt; the user can interact with your software (e.g., install on one computer, no reverse-engineering, etc.).&lt;/li&gt;
&lt;li&gt;It’s a standard way to prevent misuse and protect intellectual property while granting users the rights they need to use the software.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;EULAs are often long and filled with legal jargon, which can frustrate users.&lt;/li&gt;
&lt;li&gt;Enforcing an EULA can be difficult across jurisdictions, especially when selling globally.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. &lt;strong&gt;SaaS Agreement: Rent, Don’t Own&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: You’re not buying the software, you’re just borrowing it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: A SaaS (Software as a Service) agreement governs how users can access and use cloud-based software. Rather than "owning" the software, users subscribe to the service, with the provider retaining all rights to the software and its infrastructure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Cloud-based applications and services where customers are paying for ongoing access rather than a one-time download.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You retain &lt;strong&gt;full control&lt;/strong&gt; of the software and can update or modify it whenever necessary.&lt;/li&gt;
&lt;li&gt;The subscription model can create a continuous revenue stream, and you don’t have to worry about piracy in the traditional sense since the software is never directly installed by the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If your infrastructure fails or your servers go down, your customers lose access, which could create dissatisfaction.&lt;/li&gt;
&lt;li&gt;Legal and compliance challenges are often greater for SaaS providers, especially when dealing with global markets and data privacy laws.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. &lt;strong&gt;Shrink-Wrap and Click-Wrap Licenses: Old-School Meets New-School&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Simple but effective.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: These licenses are all about &lt;strong&gt;consent by action&lt;/strong&gt;. With shrink-wrap licenses (think of boxed software), the license agreement is accepted when the user opens the packaging. Click-wrap licenses are their digital counterpart—users accept the terms by clicking "I Agree" during installation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Software that is distributed both physically and digitally, especially older programs or those with straightforward terms.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It’s straightforward and can be &lt;strong&gt;automated&lt;/strong&gt; (e.g., software installation won't continue until the user agrees).&lt;/li&gt;
&lt;li&gt;It works well for standard commercial software that doesn’t need complex or tailored agreements.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Shrink-wrap licenses are becoming outdated as digital distribution takes over.&lt;/li&gt;
&lt;li&gt;Users might just click "Agree" without reading, which could create legal headaches later if there's a dispute.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. &lt;strong&gt;Commercial License: License to Sell&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Money talks, and software sells.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: A commercial license allows users to purchase software under a set of terms, often restricting how they can distribute, modify, or copy the software. It’s designed to give you, the developer, &lt;strong&gt;monetary compensation&lt;/strong&gt; for your work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Developers who want to &lt;strong&gt;sell&lt;/strong&gt; their software for profit and maintain strict control over its use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You retain all rights to your software, and customers are legally bound to your terms.&lt;/li&gt;
&lt;li&gt;This license allows you to set terms for individual or corporate usage and collect revenue based on the agreement.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You’ll need to invest in some level of &lt;strong&gt;licensing enforcement&lt;/strong&gt; to prevent unauthorized use or piracy.&lt;/li&gt;
&lt;li&gt;The more restrictive the license, the fewer freedoms the end user has, which might limit your customer base.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Why Licenses Are Critical in Closed Source Projects&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Licenses aren’t just formalities—they are your &lt;strong&gt;first line of defense&lt;/strong&gt; against misuse, theft, and even legal disputes. Here’s why adding a license to your closed source project is a must:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. &lt;strong&gt;Control Over Your Code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Licenses give you control over how your software is distributed and used. Without one, your software is left in a legal gray zone, and users might assume they can do whatever they want with it.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. &lt;strong&gt;Prevention of Unauthorized Use&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;By setting clear terms, you can prevent users from illegally copying, redistributing, or reverse-engineering your code. This is particularly crucial in competitive industries where intellectual property theft can cost you big time.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. &lt;strong&gt;Monetization&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;For commercial and proprietary licenses, you have the right to charge users for your software and dictate how it can be used in business environments. Without a proper license, collecting payment or enforcing contracts would be challenging.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. &lt;strong&gt;Legal Protection&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A well-crafted license protects you from lawsuits or legal issues down the road. For example, if your software crashes or causes damage, a license can include disclaimers that limit your liability. In other words, &lt;strong&gt;it’s your safety net&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How to Choose the Right Closed Source License for Your Project&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Do you want complete control?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A &lt;strong&gt;proprietary license&lt;/strong&gt; ensures that nobody can do anything with your software unless you explicitly allow it. It’s ideal for companies or developers who want to protect their code and monetize it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Are you offering a service rather than software?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
If you’re in the cloud-based software game, a &lt;strong&gt;SaaS agreement&lt;/strong&gt; is the way to go. You keep all control over the software, while users pay for access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Are you worried about users reverse-engineering or modifying your software?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Go for a &lt;strong&gt;commercial license&lt;/strong&gt; or an &lt;strong&gt;EULA&lt;/strong&gt;, which lays out specific terms about what users can and can’t do.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Need something simple for digital distribution?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A &lt;strong&gt;click-wrap license&lt;/strong&gt; is easy to implement for standard software and ensures users agree to your terms before using the software.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion: Cover Your Code’s Back!&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Choosing the right license for your closed source project is crucial to protecting your intellectual property, enforcing your rights, and ensuring that you get compensated for your hard work. Not only can it prevent unauthorized use or distribution, but it can also keep you out of legal hot water when things go wrong.&lt;/p&gt;

&lt;p&gt;Whether you want tight control with a proprietary license or you’re providing a service with a SaaS agreement, there’s a license out there for every project. And remember, without a license, your code is like an unlocked door—anyone can come in and take what they want. So, lock it down and keep it safe!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;References&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.techopedia.com/definition/2513/end-user-license-agreement-eula" rel="noopener noreferrer"&gt;End-User License Agreement (EULA)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lawinsider.com/resources/insights/shrinkwrap-vs-clickwrap-agreements-which-is-better-for-you" rel="noopener noreferrer"&gt;Shrink-Wrap and Click-Wrap Licenses&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.contractscounsel.com/t/us/saas-agreement" rel="noopener noreferrer"&gt;SaaS Agreements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.law.cornell.edu/wex/proprietary_software" rel="noopener noreferrer"&gt;Proprietary Software Licensing Explained&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.techrepublic.com/article/how-to-manage-software-licenses-in-the-enterprise/" rel="noopener noreferrer"&gt;Commercial Software Licenses&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my portfolio &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

&lt;p&gt;Happy coding! 🎉&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>documentation</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Fun Guide to Open Source Licenses: Finding the Perfect Fit for Your Project</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Sat, 19 Oct 2024 12:25:33 +0000</pubDate>
      <link>https://forem.com/jeferson0993/a-fun-guide-to-open-source-licenses-finding-the-perfect-fit-for-your-project-6a9</link>
      <guid>https://forem.com/jeferson0993/a-fun-guide-to-open-source-licenses-finding-the-perfect-fit-for-your-project-6a9</guid>
      <description>&lt;p&gt;Welcome to the magical world of &lt;strong&gt;open source licenses&lt;/strong&gt;—where code runs free, but with a few rules attached. If you're starting an open source project, or contributing to one, you might be wondering: &lt;em&gt;"Do I really need a license for this?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Spoiler alert: Yes, you do! &lt;/p&gt;

&lt;p&gt;Licenses are like the rules of the road for your code. They tell people what they can and can't do with it. But with so many licenses floating around, which one should you choose? Don’t worry—I’m here to break down the most popular ones, show you their quirks, and help you decide which one is perfect for your project!&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;strong&gt;MIT License: The Cool Kid of Licenses&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Super chill, super permissive.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: Almost anything. People can use, modify, distribute, and even sell your code with no strings attached, as long as they give you credit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: If you’re looking for a &lt;strong&gt;"code belongs to the streets"&lt;/strong&gt; vibe, the MIT license is your go-to. It's simple, concise, and gets the job done without hassle.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You don't care what people do with your code, as long as they shout you out.&lt;/li&gt;
&lt;li&gt;It's easy to understand, making it great for both small and large projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you want more control over how your code is used (e.g., no commercial use or modifications without permission), this might be too lenient.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. &lt;strong&gt;GNU General Public License (GPL): The Share-Alike License&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: You can play with my code, but &lt;strong&gt;you gotta share&lt;/strong&gt; what you build with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: You can use, modify, and distribute the code, but if you share your project, it must also be licensed under the GPL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Those who love community-driven projects and want to ensure that the open source spirit lives on in all derivatives of their code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You're passionate about keeping code open. If someone builds on your code, they &lt;strong&gt;have to share&lt;/strong&gt; their work under the same license.&lt;/li&gt;
&lt;li&gt;It promotes collaboration and prevents proprietary takeovers of your work.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Some businesses avoid GPL because they don’t want to open-source their entire project. It's not a good fit if you're open to commercial use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. &lt;strong&gt;Apache License 2.0: The Business-Friendly Option&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Open source but cool with making money, just don't sue me.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: It’s a permissive license like MIT, but it adds explicit protection against patent claims.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Developers who want to allow others to use their code commercially, but with some legal safeguards in place.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It's friendly to commercial use without forcing others to open-source their modifications.&lt;/li&gt;
&lt;li&gt;It has strong protections for contributors, including a clause that prevents patent trolls from attacking your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It’s a bit longer and more complicated than MIT, and some find the added legal jargon unnecessary for smaller projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. &lt;strong&gt;BSD License (3-Clause): The Academic One&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Similar to MIT, but with a few more words and restrictions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: Permissive like MIT, but it includes a clause preventing others from using your name to promote derivative works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Developers who want a permissive license but don’t want their name plastered all over projects they didn’t directly create.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you're okay with others doing pretty much whatever they want with your code, but don’t want them to use &lt;strong&gt;your name&lt;/strong&gt; to do it.&lt;/li&gt;
&lt;li&gt;It’s very popular in academic and scientific communities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It's more restrictive than MIT, and the additional clause might be unnecessary for many projects.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. &lt;strong&gt;Creative Commons (CC0): No Rights Reserved&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: Do whatever you want—literally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: This is the most permissive of all licenses—it's essentially the public domain. You give up all rights to the code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Projects where you truly don’t care what happens to your work, and want it to be free for any use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The code can be used by anyone, anywhere, for any purpose. No strings attached.&lt;/li&gt;
&lt;li&gt;If you want to contribute to the public domain and have absolutely no restrictions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You get &lt;strong&gt;zero&lt;/strong&gt; control. Once it’s out there, it’s gone for good. No attribution or anything.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. &lt;strong&gt;Mozilla Public License (MPL 2.0): The Middle Ground&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Vibe Check&lt;/strong&gt;: You can keep your project private, but share your modifications to open-source parts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What It Covers&lt;/strong&gt;: You can use and modify MPL-covered code, but you must share the changes you make to the original open-source files.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ideal For&lt;/strong&gt;: Developers who want a &lt;strong&gt;compromise&lt;/strong&gt; between permissive licenses and stricter copyleft licenses like GPL.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You’d Love It:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It strikes a balance. You can use MPL-covered code in proprietary projects, but if you modify open-source parts, those changes have to be shared.&lt;/li&gt;
&lt;li&gt;It’s great for large software projects where only certain modules need to be open-source.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Why You Might Swipe Left:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It’s not as permissive as MIT or Apache, but not as strict as GPL. Some might find it an odd middle-ground.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;How to Choose the Right License for Your Project&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Do you want total freedom?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Go with MIT or BSD. These licenses are like handing out candy—everyone can enjoy them with little to no restrictions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Do you want others to contribute and share back?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
GPL is your best buddy. If you’re all about keeping the open-source community alive, this is the way to go.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Are you concerned about patents?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Apache 2.0 has got your back with patent protections while staying permissive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Need some balance?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
MPL is your middle ground, allowing proprietary code to coexist with open-source parts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Want to go full public domain?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
CC0 is your path to ultimate code freedom. Just let it go!&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://opensource.org/licenses/MIT" rel="noopener noreferrer"&gt;MIT License&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnu.org/licenses/gpl-3.0.en.html" rel="noopener noreferrer"&gt;GNU General Public License&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.apache.org/licenses/LICENSE-2.0" rel="noopener noreferrer"&gt;Apache License 2.0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://opensource.org/licenses/BSD-3-Clause" rel="noopener noreferrer"&gt;BSD 3-Clause License&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mozilla.org/en-US/MPL/2.0/" rel="noopener noreferrer"&gt;Mozilla Public License&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://creativecommons.org/share-your-work/public-domain/cc0/" rel="noopener noreferrer"&gt;Creative Commons CC0&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And there you have it! Open source licenses don’t have to be boring legal documents. Choose the one that matches your project's goals, and set your code free (with a few rules attached, of course)!&lt;/p&gt;




&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my portfolio &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

&lt;p&gt;Happy coding! 🎉&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>opensource</category>
      <category>documentation</category>
    </item>
    <item>
      <title>How to Write a Cookie Policy for Your Web App: A Step-by-Step Guide with Code Examples 🍪</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Fri, 11 Oct 2024 15:10:26 +0000</pubDate>
      <link>https://forem.com/jeferson0993/how-to-write-a-cookie-policy-for-your-web-app-a-step-by-step-guide-with-code-examples-59i3</link>
      <guid>https://forem.com/jeferson0993/how-to-write-a-cookie-policy-for-your-web-app-a-step-by-step-guide-with-code-examples-59i3</guid>
      <description>&lt;p&gt;If you've read through the previous blog post, you now know what cookies are and why you need a cookie policy. In this tutorial, we’ll go a step further and walk through how to create a cookie policy and implement it in your web app using JavaScript. We’ll also look at how to manage cookies and give users the ability to control their cookie settings.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: The HTML Structure of Your Cookie Policy Page
&lt;/h3&gt;

&lt;p&gt;First things first, we need a place to display the cookie policy to users. You should create a &lt;strong&gt;Cookie Policy&lt;/strong&gt; page where users can easily access the information. Here’s a basic HTML structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Cookie Policy&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"styles.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Our Cookie Policy 🍪&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"what-are-cookies"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;What Are Cookies?&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Cookies are small files stored on your device to remember information about you, like your preferences and previous activity on our site.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"types-of-cookies"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Types of Cookies We Use&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;&lt;/span&gt;Essential Cookies:&lt;span class="nt"&gt;&amp;lt;/strong&amp;gt;&lt;/span&gt; These keep the website functioning.&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;&lt;/span&gt;Analytics Cookies:&lt;span class="nt"&gt;&amp;lt;/strong&amp;gt;&lt;/span&gt; These track how you interact with our site to improve performance.&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;strong&amp;gt;&lt;/span&gt;Advertising Cookies:&lt;span class="nt"&gt;&amp;lt;/strong&amp;gt;&lt;/span&gt; These help us serve you relevant ads.&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"how-to-manage-cookies"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;How to Manage Your Cookies&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;You can manage or disable cookies directly in your browser settings. Disabling cookies might affect your experience on our site.&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Setting Cookies with JavaScript 🍫
&lt;/h3&gt;

&lt;p&gt;To store cookies in your web app, you can use JavaScript. Here’s how to create and set cookies in JavaScript:&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="c1"&gt;// Function to set a cookie&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;setCookie&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="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;days&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;expires&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&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;days&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;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;days&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
    &lt;span class="nx"&gt;expires&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;; expires=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUTCString&lt;/span&gt;&lt;span class="p"&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="nx"&gt;cookie&lt;/span&gt; &lt;span class="o"&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;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;expires&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;; path=/&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="c1"&gt;// Example: Setting a cookie named "userConsent" that expires in 30 days&lt;/span&gt;
&lt;span class="nf"&gt;setCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;userConsent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;accepted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function allows you to create a cookie by specifying its name, value, and how long it should last before expiring.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Checking for and Reading Cookies 🍪
&lt;/h3&gt;

&lt;p&gt;To check if a user has already accepted your cookie policy, you can read cookies with this simple JavaScript function:&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="c1"&gt;// Function to get a cookie by name&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getCookie&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="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nameEQ&lt;/span&gt; &lt;span class="o"&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;=&lt;/span&gt;&lt;span class="dl"&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;cookiesArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cookie&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&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="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&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;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;cookiesArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&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;let&lt;/span&gt; &lt;span class="nx"&gt;cookie&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cookiesArray&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;trim&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;cookie&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nameEQ&lt;/span&gt;&lt;span class="p"&gt;)&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;cookie&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substring&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nameEQ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cookie&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&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="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Example: Checking if the user has accepted the cookie policy&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userConsent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;userConsent&lt;/span&gt;&lt;span class="dl"&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;userConsent&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;accepted&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;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;User has accepted the cookie policy.&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;else&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;User has not accepted the cookie policy.&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;This function searches for a specific cookie by its name and returns its value if found.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Implementing a Cookie Consent Banner 📢
&lt;/h3&gt;

&lt;p&gt;Now that you can set and read cookies, it’s time to create a consent banner. When the user first visits the site, they’ll see a banner asking if they accept your cookie policy. If they accept, you’ll set a cookie to remember their choice.&lt;/p&gt;

&lt;p&gt;Here’s the HTML and JavaScript for the consent banner:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"cookie-banner"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"display: none; position: fixed; bottom: 0; background: #333; color: #fff; padding: 10px; width: 100%; text-align: center;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;We use cookies to improve your experience. &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"cookie-policy.html"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"color: #fff;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Read more&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"accept-cookies"&lt;/span&gt; &lt;span class="na"&gt;style=&lt;/span&gt;&lt;span class="s"&gt;"background: #28a745; color: #fff; border: none; padding: 10px 20px; cursor: pointer;"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Accept&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;// Check if the user has already accepted cookies&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;getCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;userConsent&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="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="s2"&gt;cookie-banner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;display&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;block&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="c1"&gt;// Set the cookie when the user accepts&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="s2"&gt;accept-cookies&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;userConsent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;accepted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&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="s2"&gt;cookie-banner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;display&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;none&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="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The banner will only appear if the user hasn't previously accepted the cookie policy (i.e., if there’s no &lt;code&gt;userConsent&lt;/code&gt; cookie).&lt;/li&gt;
&lt;li&gt;When the user clicks the &lt;strong&gt;Accept&lt;/strong&gt; button, a &lt;code&gt;userConsent&lt;/code&gt; cookie is created, and the banner is hidden.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Letting Users Manage Their Cookies ⚙️
&lt;/h3&gt;

&lt;p&gt;As part of the cookie policy, users should be able to manage their cookies. Most browsers allow users to manage their cookies through settings, but you can also offer a simple "delete cookie" option within your app:&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="c1"&gt;// Function to delete a cookie&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;deleteCookie&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="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="nx"&gt;cookie&lt;/span&gt; &lt;span class="o"&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;=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;&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="c1"&gt;// Example: Deleting the "userConsent" cookie&lt;/span&gt;
&lt;span class="nf"&gt;deleteCookie&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;userConsent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Show the cookie banner again after deleting the cookie&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="s2"&gt;cookie-banner&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;display&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;block&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;This function deletes the specified cookie by setting its expiration date to a past date.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Styling Your Cookie Policy 🍬
&lt;/h3&gt;

&lt;p&gt;You can style your cookie banner and policy page with CSS to make them visually appealing. Here’s a basic example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#cookie-banner&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;#accept-cookies&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#28a745&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&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;h3&gt;
  
  
  Step 7: Testing and Iterating 🔍
&lt;/h3&gt;

&lt;p&gt;After implementing your cookie policy, test your app thoroughly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure the consent banner appears on the first visit.&lt;/li&gt;
&lt;li&gt;Confirm the banner disappears after acceptance and doesn't reappear on subsequent visits.&lt;/li&gt;
&lt;li&gt;Check the cookies in your browser's developer tools to ensure they’re being set correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 8: Updating Your Policy 📅
&lt;/h3&gt;

&lt;p&gt;Cookie policies aren’t a one-and-done thing. If your app starts using new cookies or third-party services that use cookies (e.g., Google Analytics or Facebook Pixel), &lt;strong&gt;update&lt;/strong&gt; your cookie policy and banner to reflect these changes.&lt;/p&gt;




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

&lt;p&gt;And there you have it! A complete guide to creating a cookie policy, from setting cookies to managing user consent. With this in place, you’ll not only be compliant with privacy regulations like GDPR, but you’ll also ensure that your users feel informed and empowered.&lt;/p&gt;

&lt;p&gt;Happy coding, and enjoy baking those (digital) cookies! 🍪&lt;/p&gt;

&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my portfolio &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

&lt;h4&gt;
  
  
  References:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://gdpr.eu/cookies/" rel="noopener noreferrer"&gt;GDPR Cookie Guidelines&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies" rel="noopener noreferrer"&gt;Mozilla’s Cookies Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.cookiebot.com/en/cookie-policy/" rel="noopener noreferrer"&gt;Cookie Consent by Cookiebot&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Happy coding! 🎉&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>A Beginner's Guide to IndexedDB</title>
      <dc:creator>Jeferson F Silva</dc:creator>
      <pubDate>Wed, 25 Sep 2024 23:49:12 +0000</pubDate>
      <link>https://forem.com/jeferson0993/a-beginners-guide-to-indexeddb-2f6e</link>
      <guid>https://forem.com/jeferson0993/a-beginners-guide-to-indexeddb-2f6e</guid>
      <description>&lt;h2&gt;
  
  
  A Tutorial on Using Client-Side Storage in Web Apps
&lt;/h2&gt;

&lt;p&gt;When building modern web applications, especially progressive web apps (PWAs), it's crucial to have a way to store data offline. IndexedDB is a powerful client-side database that allows web apps to store and retrieve data, even when the user is offline. This guide will walk you through the basics of IndexedDB, showing you how to create, read, update, and delete data (CRUD operations) within your web app.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is IndexedDB?
&lt;/h3&gt;

&lt;p&gt;IndexedDB is a low-level API for client-side storage of large amounts of structured data, including files and blobs. Unlike localStorage, IndexedDB allows you to store complex data types, not just strings. It uses an asynchronous, transactional database model, which makes it powerful for applications needing to handle large datasets or offline data syncing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use IndexedDB?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Offline capabilities:&lt;/strong&gt; Ideal for Progressive Web Apps (PWAs) and offline-first applications.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Storage capacity:&lt;/strong&gt; IndexedDB can store far more data compared to localStorage (which is limited to about 5-10MB).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flexibility:&lt;/strong&gt; Store complex objects like arrays, objects, and even blobs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Asynchronous:&lt;/strong&gt; Operations do not block the UI thread, meaning your app remains responsive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Getting Started: Setting Up IndexedDB
&lt;/h3&gt;

&lt;p&gt;Let's dive into the core steps for working with IndexedDB. We will cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating or opening a database&lt;/li&gt;
&lt;li&gt;Creating object stores (tables)&lt;/li&gt;
&lt;li&gt;Adding data&lt;/li&gt;
&lt;li&gt;Reading data&lt;/li&gt;
&lt;li&gt;Updating data&lt;/li&gt;
&lt;li&gt;Deleting data&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 1: Opening a Database
&lt;/h3&gt;

&lt;p&gt;To interact with IndexedDB, you first need to open a connection to the database. If the database doesn't exist, it will be created.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;indexedDB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MyCustomersDatabase&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onerror&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Database error:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;errorCode&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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;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="s1"&gt;Database opened successfully&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onupgradeneeded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;objectStoreNames&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&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;objectStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createObjectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&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="na"&gt;keyPath&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
        &lt;span class="nx"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;name&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="na"&gt;unique&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="nx"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;email&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="na"&gt;unique&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&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="s1"&gt;Object store created.&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;Here’s what’s happening:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;indexedDB.open&lt;/code&gt; opens or creates the database.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onerror&lt;/code&gt; handles any errors when opening the database.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onsuccess&lt;/code&gt; is triggered when the database connection is successfully opened.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;onupgradeneeded&lt;/code&gt; is fired when the database needs to be upgraded (e.g., if this is the first time opening the database or if the version changes). It’s where you define your object stores (think of them as tables in SQL).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Adding Data to IndexedDB
&lt;/h3&gt;

&lt;p&gt;Now that we have our database and object store set up, let’s add some data to it.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addCustomer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customer&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;readwrite&lt;/span&gt;&lt;span class="dl"&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;objectStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&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;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&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="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="s1"&gt;Customer added:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onerror&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error adding customer:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;errorCode&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;customer&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="mi"&gt;1&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;John Doe&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;john@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="nf"&gt;addCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customer&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;Here’s what’s happening:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We create a transaction with &lt;code&gt;'readwrite'&lt;/code&gt; access to allow modifications.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;add()&lt;/code&gt; method is used to insert data into the object store.&lt;/li&gt;
&lt;li&gt;We listen for success and error events to confirm whether the data was added successfully.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Reading Data from IndexedDB
&lt;/h3&gt;

&lt;p&gt;Reading data from IndexedDB is also straightforward. Let’s retrieve the customer we just added by using the &lt;code&gt;get()&lt;/code&gt; method.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getCustomer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&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;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;transaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;readonly&lt;/span&gt;&lt;span class="dl"&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;objectStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&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;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&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;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;customer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&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="s1"&gt;Customer found:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customer&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="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="s1"&gt;Customer not found.&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;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onerror&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error fetching customer:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;errorCode&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;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="nf"&gt;getCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&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="c1"&gt;// Fetch customer with ID 1&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Updating Data in IndexedDB
&lt;/h3&gt;

&lt;p&gt;To update an existing record, we can use the &lt;code&gt;put()&lt;/code&gt; method, which works similarly to &lt;code&gt;add()&lt;/code&gt; but replaces the record if the key already exists.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updateCustomer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customer&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;readwrite&lt;/span&gt;&lt;span class="dl"&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;objectStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&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;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&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="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="s1"&gt;Customer updated:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;

    &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onerror&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error updating customer:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;errorCode&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updatedCustomer&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="mi"&gt;1&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;Jane Doe&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;jane@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="nf"&gt;updateCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updatedCustomer&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;h3&gt;
  
  
  Step 5: Deleting Data from IndexedDB
&lt;/h3&gt;

&lt;p&gt;Finally, to delete a record, use the &lt;code&gt;delete()&lt;/code&gt; method.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;deleteCustomer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&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;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;transaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;readwrite&lt;/span&gt;&lt;span class="dl"&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;objectStore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customers&lt;/span&gt;&lt;span class="dl"&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;request&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;objectStore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&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;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&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="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="s1"&gt;Customer deleted.&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;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onerror&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error deleting customer:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;errorCode&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;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onsuccess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&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="nf"&gt;deleteCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;db&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="c1"&gt;// Delete customer with ID 1&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;IndexedDB is a robust solution for handling client-side data storage, especially in offline-first web apps. By following this guide, you’ve learned how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open and create a database&lt;/li&gt;
&lt;li&gt;Create object stores&lt;/li&gt;
&lt;li&gt;Add, read, update, and delete data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With IndexedDB, you can build more resilient web applications that store data locally and work even without an internet connection.&lt;/p&gt;

&lt;h3&gt;
  
  
  About Me
&lt;/h3&gt;

&lt;p&gt;As a dedicated remote web developer, I specialize in crafting modern, scalable web applications with a focus on performance and user experience. My expertise spans across full-stack development, utilizing cutting-edge technologies and best practices to deliver tailored solutions for diverse client needs. I’m committed to creating responsive, dynamic websites that bring ideas to life. Explore my portfolio &lt;a href="https://jef-dev.web.app" rel="noopener noreferrer"&gt;here&lt;/a&gt; to see my latest projects, and connect with me on &lt;a href="https://www.linkedin.com/in/jeferson-silva-b68a56302/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; to discuss how I can help bring your next project to fruition!&lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MDN Web Docs - IndexedDB API&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A comprehensive guide on how IndexedDB works, its API methods, and use cases.&lt;br&gt;&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API" rel="noopener noreferrer"&gt;MDN IndexedDB Guide&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Google Developers - IndexedDB&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
A detailed article covering best practices and use of IndexedDB for building offline-capable web apps.&lt;br&gt;&lt;br&gt;
&lt;a href="https://developers.google.com/web/ilt/pwa/working-with-indexeddb" rel="noopener noreferrer"&gt;Google Developers - IndexedDB&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;W3C Indexed Database API&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
The official specification from W3C outlining the technical implementation and structure of IndexedDB.&lt;br&gt;&lt;br&gt;
&lt;a href="https://www.w3.org/TR/IndexedDB/" rel="noopener noreferrer"&gt;W3C IndexedDB Spec&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These resources will provide additional depth and context if you're looking to explore more about IndexedDB beyond this tutorial!&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

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