Below you will find pages that utilize the taxonomy term “nuxt”
Posts
How to add third party scripts & inline scripts in your Nuxt.js app?
Problem statement Let’s say you have created a Nuxt app and one day your client or your boss asks you to add some snippet of code to every page of the site for analytics purposes. For example:
<!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-111111111-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-111111111-1'); </script> Solution Open your nuxt.config.js file and update the head section as follows:
Posts
How to add authentication to your universal Nuxt app using nuxt/auth module?
Recently I was working on a Nuxt.js app and had to add authentication to it. First thing I thought was to use vuex to store two fields in a state:
isLoggedIn: a boolean representing whether user is logged in or not loggedInUser: an object containing the user details for the session that we get from server And then I added a middleware on pages where I wanted to restrict access to logged in users only.