Skip to content

Instantly share code, notes, and snippets.



Last active Jun 8, 2021
What would you like to do?
<h1> Feed </h1>
<h3> This page is for users only </h3>
<script setup>
import firebase from 'firebase'
import { useRouter } from 'vue-router'
import { onBeforeUnmount } from 'vue'
const router = useRouter()
const authListener = firebase.auth().onAuthStateChanged(function(user) {
if (!user) { // not logged in
alert('you must be logged in to view this. redirecting to the home page')
onBeforeUnmount(() => {
// clear up listener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment