Nuxt Amplify Auth Starter is a starter template for adding Amplify Auth to a Nuxt.js single page web application. All you have to do is connect your Amazon Web Services account to it by using the Amplify CLI, and you will be able to add Amazon Cognito Authentication to your app in minutes.
You must have the Amplify CLI installed on your machine to continue with this installation. In order to do this, head on over to the Amplify docs.
- Run
amplify init
in your terminal. - When prompted "Enter a name for the project", name it whatever you would like.
- When prompted "Enter a name for the environment", I recommend naming it dev, but this is also up to you.
- When prompted "Choose your default code editor", choose the code editor you use from the list.
- When prompted "Choose the type of app that you're building", choose javascript.
- When prompted "What javascript framework are you using", choose vue.
- When prompted "Source Directory Path:", choose . (just a period) since the default Nuxt.js structure doesn't use a src directory.
- When prompted "Distribution Directory Path:", choose the default dist.
- When prompted "Build Command:", choose the default
npm.cmd run-script build
. - When prompted "Start Command:", enter
npm.cmd run-script start
. - When prompted "Do you want to use an AWS profile?", choose Y and select the profile you want to use.
- Run
amplify add auth
in your terminal. - When prompted "Do you want to use the default authentication and security configuration?", choose Default configuration.
- When prompted "How do you want users to be able to sign in?", choose Username.
- When prompted "Do you want to configure advanced settings?", choose No, I am done.
- Run
amplify add hosting
in your terminal. - When prompted Select the environment setup, choose DEV (S3 only with HTTP). The difference between DEV and PROD in this situation is what all resources AWS provisions for your app when you publish it. DEV only uses an S3 for hosting your static files; whereas, PROD uses S3 for hosting your static files, CloudFront to deliver your static files through a CDN, and HTTPS.
- When prompted hosting bucket name, name it whatever you would like or choose the default.
- When prompted index doc for the website, choose the default.
- When prompted error doc for the website, choose the default.
- Run
amplify push
in your terminal. - When prompted "Are you sure you want to continue?", choose Y. List step takes a few minutes to complete.
- Run
npm run dev
in your terminal.
- Run
amplify publish
to auto-build your SPA and upload it to your S3 bucket.