Example project using Aspire with an Expo (React Native) frontend and an ASP.NET Core backend that uses ASP.NET Core Identity for authentication backed by PostgreSQL.
This project requires the following:
- .NET SDK 10.0 or later
- Node.js 20.19.0 or later
- Docker Desktop or Podman
To run this project, do the following:
- Start Docker Desktop or Podman if it is not already running
- Use one of the following:
- .NET CLI: In the
AspireIdentityExpo.AppHostdirectory, rundotnet runand then open the dashboard using the URL output to the console. - Aspire CLI: In the repo directory, run
aspire runand then open the dashboard using the URL output to the console. - Code Editor/IDE: Use the run command in a code editor or IDE such as Visual Studio Code.
- .NET CLI: In the
An Aspire AppHost which handles orchestration and hosts the Aspire dashboard.
Uses:
- Aspire.Hosting.PostgreSQL - Handles starting up the PostgreSQL container (with pgAdmin) and providing the database to the API service
- Aspire.Hosting.JavaScript - Handles launching and configuring the Expo frontend
An ASP.NET Core minimal APIs backend that exposes ASP.NET Core Identity API endpoints for authentication and account management.
Note
The LoggingEmailSender is used in place of a real email sender. Instead of sending emails, it logs confirmation links and password reset codes as structured log entries, which are accessible from the Structured tab in the Aspire dashboard. For production use, replace it with a real IEmailSender<ApplicationUser> implementation.
Uses:
- Aspire.Npgsql.EntityFrameworkCore.PostgreSQL - Handles configuring the Entity Framework Core connection to PostgreSQL
- Microsoft.AspNetCore.Identity.EntityFrameworkCore - Provides cookie-based and token-based authentication with support for email confirmation, password reset, two-factor authentication (TOTP), and recovery codes
- Scalar.AspNetCore - Provides an interactive API reference in development
An Expo frontend supporting web, iOS, and Android that authenticates users via the ASP.NET Core Identity API endpoints.
Note
On web, HTTP-only cookies are used instead of tokens as a security best practice. On native, tokens are persisted via expo-secure-store.
Features:
- 👤 Sign up and sign in
- 📧 Email confirmation
- 🔑 Forgot password and password reset
- 📱 Two-factor authentication (TOTP) setup and sign-in
- 🛡️ Recovery code management
- ✏️ Change email and change password
- 🔒 Protected routes
Uses:
- Expo + Expo Router - Provides the React Native app framework and file-based routing
- Uniwind - Applies Tailwind CSS styles to React Native components
- React Native Reanimated - Provides smooth, performant animations and transitions
- React Native Reusables - Provides shadcn/ui-inspired universal components for React Native
- TanStack Query - Handles server state and data fetching
- React Hook Form + Zod - Manages form state and validation
- expo-secure-store - Persists auth tokens securely on native platforms
- Lucide React Native - Provides icons