Skip to content

Latest commit

 

History

History
138 lines (98 loc) · 6.06 KB

README.md

File metadata and controls

138 lines (98 loc) · 6.06 KB

Netlify Notes

Introduction 🌟

Embarking on the journey of deploying your web application is an exciting adventure. This step-by-step guide will walk you through the process, starting from setting up your project in VS Code, to committing it to GitHub, and finally launching it on the powerful Netlify platform. 🚀 Experience the magic of seamless continuous deployment and the ease of custom domain setup as your web app takes flight!

Step 1: Setting Up Your React Web Application in VS Code 🚀

  1. Create Your Project 🏗️:

    • Open VS Code and create a new folder for your React web application. Call it something meaningful, like "YourReactApp."
    • Use npm create vite@latest YourReactApp to set up a new React project with Vite. Replace "YourReactApp" with your desired project name.
    ? Select a framework
    > react
    vue
    preact
    
    • Choose "react" by highlighting it using up or down arrow keys and pressing Enter. This ensures that your Vite project is set up with React as the chosen framework, paving the way for building dynamic and interactive user interfaces.
  2. Organize Your Structure 🧱:

    • For a basic HTML, CSS, JS app:
      • Create two essential folders, css and js, within your project to house your styles and scripts.
      • Migrate your existing styles.css to the css folder and script.js to the js folder.
         📦 YourWebApp
         ┣ 📂 css
         ┃ ┗ 📜 styles.css
         ┣ 📂 js
         ┃ ┗ 📜 script.js
         ┣ 📜 index.html
         ┗ 📜 README.md
      
    • For a React app created with Vite, the folder structure is handled automatically.

Step 2: Git It Together! 🔄

  1. Initiate Git 🚀:

    • Open the terminal in VS Code, navigate to your project folder, and type:
      git init
  2. Commit Your Beginning 📦:

    • Stage your changes and make your first commit:
      git add .
      git commit -m "Initial commit: Organize project structure"

Step 3: GitHub - Your Project's Online Home 🏠

  1. Create a Repository 🗄️:

    • Visit GitHub and create a new repository. Skip the license for now.
  2. Connect with GitHub 🔗:

    • Follow the instructions to link your local repository with the one on GitHub:
      git remote add origin <repository-url>
      git branch -M main
      git push -u origin main

Step 4: Launching Your React Web App on Netlify 🚀

  1. Sign Up for Netlify 🌐:

    • Head over to Netlify and sign up. Once done, take in the view of your Netlify dashboard.
  2. Connect with Git 🔄:

    • In your Netlify dashboard, spot the "New site from Git" button and give it a friendly click.
    • Choose your Git provider—GitHub, GitLab, or Bitbucket—and grant Netlify the access it needs to fetch your code.
  3. Select Your Repository 📁:

    • Pick the repository housing your React web application. It's like choosing the perfect canvas for your digital masterpiece.
  4. Automatic Configurations (It's Smart!) 🤖:

    • Netlify, being the clever companion it is, will try to automatically detect essential build settings based on common configurations. Review these and tweak if necessary.
      • For React/Vite projects, the default settings are usually optimal. However, feel free to adjust if needed.
  5. Environment Variables (For Secrets) 🔐:

    • If your project requires special environment variables, you can add them right in the Netlify dashboard. It's the secret sauce for things like API keys or configuration settings.
  6. Initiate Deployment 🚀:

    • With configurations in place, hit the "Deploy site" button. This sets the magic in motion.

Step 5: Customize Build Settings and Add Redirects (React) 🛠️

  1. Fine-tune with netlify.toml ⚙️:

    • Personalize your build settings further by creating a netlify.toml file in your project's root.

    • Specify the build command and publish directory according to your project's needs.

      [build]
        command = "CI=false npm run build"
        publish = "dist"
  2. Setting Up Redirects 🔄:

    • Create a _redirects file in the public folder of your React project.

    • This file will contain rules for redirecting traffic on your site.

      For example,

      If you want to redirect all requests to /* to /index.html with a 200 status code, your _redirects file would look like this:

      /* /index.html 200
      
    • This rule specifies a 200 redirect (OK response) from any path (/*) to /index.html.

    • Customize these rules based on your specific redirection needs.

    • Make sure to add this file to your version control system (e.g., Git) and deploy it along with your project.

    • When deploying on Netlify, the _redirects file in the public folder will be automatically picked up during the build process.

Step 6: Launch Your React Web App 🚀

  1. Automatic or Manual? It's Your Call 📞:

    • Netlify can automatically detect changes and deploy, or you can manually trigger a deploy. Both are equally magical.
  2. Adding a Custom Domain? Fancy! 🌐

    • In Netlify, under "Site settings" and "Domain management," add your custom domain. Netlify will guide you through DNS configuration.

Step 7: Keep an Eye on Your React Web App Deployments 🚨

  1. Detailed Logs Await 📋:

    • Head to the Netlify dashboard's "Deploys" section for detailed logs. If anything goes astray, Netlify's error messages are like breadcrumbs leading you back on track.
  2. Level Up with Continuous Deployment 🔄:

    • For more automation, explore continuous deployment tools like GitHub Actions or GitLab CI. They're like magical elves handling your deployments.

Conclusion 🎉

Congratulations! Your web application has now soared to new heights on Netlify. If you encounter challenges or have questions along the way, your mentor (that's me!) is just a message away. Keep coding and exploring the vast world of web development! 🚀🌐