Skip to content

Latest commit

 

History

History
85 lines (57 loc) · 3.73 KB

README.md

File metadata and controls

85 lines (57 loc) · 3.73 KB

Nestjs Template with Supertokens Authentication

This project template provides the backend for developing a React Native application with Expo and Supertokens to authenticate. It is built with Nestjs and Supertokens.

Key Features:

  • Sign in with Apple, GitHub, Google, or Email and Password: The authentication flow supports multiple sign-in options using Supertokens.
  • Role Management: You can manage user roles and permissions within your application using Supertokens.
  • Change Password, Verify E-Mail and Delete Account Views: Connect your app to a website by adding support for deep linking.
  • Handlebars E-Mail Templates: It utilizes Expo Router, a versatile routing solution for navigating between screens in your application.

Getting Started

To use this template, follow the steps below:

  1. Install dependencies
    pnpm install
  2. Configure the Supertokens Backend with your authentication providers (Apple, GitHub, Google, etc.)
  3. Setup environment variables:
  • cp ./apps/api.env.example ./apps/api/.env

  • Update the necessary environment variables for Supertokens configuration. For example:

     SUPERTOKENS_CONNECTION_URI=your-supertokens-connection-uri
     SUPERTOKENS_API_KEY=your-supertokens-api-key
     ACCOUNT_JWT_SECRET=custom-jwt-secret # jwt secret for delete account token
     RESEND_API_KEY=your-resend-api-key # Get this from https://resend.com/api-keys
     EMAIL_FROM=test@example.com
    
  1. Start the app
    pnpm run api

Configuring the Authentication Providers

To configure Supertokens with your authentication providers, follow the documentation provided by Supertokens. This typically involves registering your app with each provider and obtaining API keys or tokens required for authentication.

Apple

Generate a private key for your Apple App ID. You can find more information about this here.

 APPLE_CLIENT_ID=your-apple-client-id
 APPLE_PRIVATE_KEY=your-apple-private-key
 APPLE_TEAM_ID=your-apple-team-id
 APPLE_KEY_ID=your-apple-key-id

GitHub

Register your app with GitHub and obtain a client ID and secret. You can find more information about this here.

 GITHUB_CLIENT_ID=your-github-client-id
 GITHUB_CLIENT_SECRET=your-github-client-secret

Google

Register your app with Google and obtain a client ID and secret. You can find more information about this here.

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

Customizing the Template

Customizing the E-Mails in the template is easy. Simply edit the Handlebars templates in the ./emails/auth folder. For Updating the HTML views, edit the files in the ./views/auth folder.

Setup Apple App site association (ASA)

For iOS, you need to setup the Apple App site association (ASA) file. This is required for deep linking to work on iOS. The File can be found in the ./public/.well-known folder. You can find more information about this here.

Known Issues

Learn more