Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Starter project adding AWS Amplify authentication (sign-up, sign-in, MFA, sign-out) with protected routing to Gatsby apps.
Gatsby Auth Starter AWS Amplify is a GitHub boilerplate that adds a full authentication flow — sign-up, sign-in, multi-factor authentication, and sign-out — to a Gatsby site by wiring it to Amazon Cognito through AWS Amplify.
This starter project implements a basic authentication flow for signing up and signing in users, as well as protected client-side routing, using the AWS Amplify framework. It is built on Gatsby's React-based static site generator and includes the frontend code and configuration needed to connect to a Cognito user pool. The repository is authored by dabit3 (Nader Dabit) and currently has 320 stars on GitHub. It is meant as a foundation you can extend when creating Gatsby applications that require user accounts.
@aws-amplify/cli and aws-amplify libraries to provision and talk to backend services.gatsby new, configuring the Amplify CLI with amplify configure, and running gatsby develop locally.Auth.signIn and related Amplify API calls fit into Gatsby.gatsby new gatsby-amplify-auth https://github.com/dabit3/gatsby-auth-starter-aws-amplify.yarn or npm install.npm install -g @aws-amplify/cli and run amplify configure.amplify init to set up the project, choosing JavaScript/React, source directory src, distribution directory public, and the provided build/start commands.amplify push to deploy the CloudFormation template that provisions the Amazon Cognito resource.gatsby develop.The starter code is publicly available on GitHub and costs nothing to download. However, you need an AWS account to deploy and run it, and the AWS resources you create (such as Amazon Cognito) may incur usage charges.
It uses AWS Amplify for CLI tooling and client libraries, and Amazon Cognito for user authentication. The amplify push step generates a CloudFormation template that includes an Amazon Cognito resource.
You need Node.js, either Yarn or npm, the Gatsby CLI, an AWS account, and the AWS Amplify CLI installed globally. The README links to a video guide for configuring the Amplify CLI.
Sign-up, sign-in, multi-factor authentication (MFA), and sign-out are all included. The template also demonstrates protected client-side routing, so you can restrict pages to authenticated users.