'How to use firebase authentication?

I want to use firebase Realtime database to authenticate my users and store their data. I just started firebase and it seems like they have updated the script tags, no video is there using that . Can someone plz tell me complete work flow

What I want ? User signs in then when the click save ,their data is saved and when the click a load button there data must be retrieved from it.

My problems

  1. If I use below given code then I have to write whole javascript in html file only as I can't access initializeApp() in my .js file
console.log(initializeApp)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Auth</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="auth">
        <div class="login">Login</div>
        <div class="logout">Logout</div>
    </div>



    <script type="module">
      // Import the functions you need from the SDKs you need
      import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.5/firebase-app.js";
    
      // Your web app's Firebase configuration
      const firebaseConfig = {
        apiKey: "AIzaSyBp8Z9sTTI6XvrFIWZ71nbx-0NbsvXED_c",
        authDomain: "todo-firebase-a8101.firebaseapp.com",
        projectId: "todo-firebase-a8101",
        storageBucket: "todo-firebase-a8101.appspot.com",
        messagingSenderId: "309943992224",
        appId: "1:309943992224:web:19d0b8a537528400a2aec5"
      };
    
      // Initialize Firebase
      const app = initializeApp(firebaseConfig);
      </script>

    <!-- <script type="module" src="https://www.gstatic.com/firebasejs/9.6.5/firebase-app.js"></script> -->
    <script src="index.js"></script>
</body>
</html>
  1. Also the commented script tag throws the same error, How to solve this?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source