https://github.com/lukesthl/nestjs-supertokens
A template of the backend for your next React Native project: Nestjs with Supertokens Authentication
https://github.com/lukesthl/nestjs-supertokens
authentication nestjs supertokens typescript
Last synced: about 2 months ago
JSON representation
A template of the backend for your next React Native project: Nestjs with Supertokens Authentication
- Host: GitHub
- URL: https://github.com/lukesthl/nestjs-supertokens
- Owner: lukesthl
- Created: 2023-08-19T14:18:05.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-01T16:11:51.000Z (over 1 year ago)
- Last Synced: 2023-10-01T19:12:45.416Z (over 1 year ago)
- Topics: authentication, nestjs, supertokens, typescript
- Language: Handlebars
- Homepage:
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
# Nestjs Template for [expo-supertokens](https://github.com/lukesthl/expo-supertokens) 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](https://nestjs.com/) and [Supertokens](https://supertokens.io/).
## Key Features:
- [**Sign in with Apple, GitHub, Google, or Email and Password**](https://supertokens.com/docs/thirdpartyemailpassword/introduction): The authentication flow supports multiple sign-in options using Supertokens.
- [**Role Management**](https://supertokens.com/docs/userroles/introduction): 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**](https://handlebarsjs.com/): 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. Clone the repository
`git clone https://github.com/lukesthl/nestjs-supertokens`
2. Install dependencies
`pnpm install`
3. Configure the Supertokens Backend with your authentication providers (Apple, GitHub, Google, etc.)
4. Setup environment variables:- `cp .env.example .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 protected]
```5. Start the app
`pnpm run start:dev`### 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](https://developer.apple.com/help/account/configure-app-capabilities/configure-sign-in-with-apple-for-the-web/).
```
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](https://docs.github.com/en/developers/apps/creating-an-oauth-app).
```
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secret
```Register your app with Google and obtain a client ID and secret. You can find more information about this [here](https://developers.google.com/identity/protocols/oauth2).
```
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](https://docs.expo.dev/guides/deep-linking/).
### Known Issues
## Learn more
- [Supertokens Documentation](https://supertokens.io/docs/)
- [Nestjs Documentation](https://docs.nestjs.com/)