Quick start
Setup with Amplify Gen 2 backend
To get up and running with the Authenticator, follow the Amplify Gen2 quickstart guide.
Setup with Amplify Gen 1 backend
To setup Amplify using the Gen1 CLI, follow the steps below:
Step 1. Configure backend
The Authenticator works seamlessly with the Amplify CLI to automatically work with your backend.
First, update @aws-amplify/cli with npm or yarn if you're using a version before 6.4.0:
npm install -g @aws-amplify/cli@latestyarn global add @aws-amplify/cli@latestNow that you have the Amplify CLI installed, you can set up your Amplify project by running amplify init in your project's root directory. Then run amplify add auth and follow the prompts to add authentication to your backend configuration.
If you have an existing backend, run amplify pull to sync your aws-exports.js with your cloud backend.
You should now have an aws-exports.js file in your src/ directory with your latest backend configuration.
Step 2. Install dependencies
npm install @aws-amplify/ui-svelte aws-amplifyyarn add @aws-amplify/ui-svelte aws-amplifyStep 3. Add the Authenticator
The quickest way to get started is by wrapping your application with the Authenticator component. Once an end-user has created an account & signed in, the underlying component is rendered with access to the user.
<script lang="ts"> import { Amplify } from 'aws-amplify'; import { Authenticator } from '@aws-amplify/ui-svelte' import "@aws-amplify/ui-svelte/styles.css"; import awsconfig from './aws-exports'; Amplify.configure(awsconfig); </script> <Authenticator> {#snippet children({ user, signOut })} <h1>Hello {user.username}!</h1> <button onclick={signOut}>Sign Out</button> {/snippet} </Authenticator>