Expo Examples

repository·master·Indexed 25 days ago

https://github.com/expo/examples

A collection of Expo examples demonstrating how to use various features, libraries, and third-party integrations within the Expo ecosystem. Includes templates and guides for implementations such as Apollo GraphQL, Auth0, AWS Amplify, Better Auth, Clerk, Convex, App Integrity, and the StickerSmash app.

Tokens
60K
Snippets
218
Records
393
Agent score
86%

What's inside expo-examples

  1. Overview of with-router-menus features

    master

    The with-router-menus example demonstrates how to use native context menus to manipulate state and data in your UI. It utilizes the following technologies:

    • Expo Router: File-based navigation.
    • Nativewind: Tailwind/className styling support.
    • Zeego: Provides native menus on iOS and Android.
    • shadcn/ui Dropdown: A custom implementation used for styled menus on the web.
  2. Understand Facebook Auth implementation via AuthSession

    master
    This example uses the AuthSession API, which is a wrapper around the WebBrowser API. WebBrowser opens a SFSafariViewController (iOS) or Chrome Custom Tab (Android) in a modal window. This approach is more secure than a WebView because it prevents code injection and allows sharing cookies with the system browser, enabling seamless re-authentication.
  3. Understand the Firebase SAML Redirect Pattern

    master

    Firebase does not support SAML (or any popup/redirect) login directly in React Native or webview components.

    The Pattern: This example uses a web server and a dummy page to provide the HTTPS protocol required by Firebase. The user authenticates in that web page, and the resulting auth token is passed back to the Expo app. The app then uses that token to log the user in.

    Deployment Requirement: Because the authentication request must originate from a webpage, you must host the files in the backend directory on a public webserver (e.g., Firebase Hosting). For local development, use the serve script.

  4. Understand the App Integrity architecture

    master

    This example demonstrates how to verify that requests come from a genuine, untampered app on a real device using Expo App Integrity.

    Platform Support

    Implementation Details

    • Client-side: The attestation/assertion flow is handled in app/index.tsx.
    • Server-side: Verification is performed via Expo Router API routes:
      • app/api/challenge+api.ts: Issues one-time challenges.
      • app/api/verify+api.ts: Verifies attestations, assertions, and tokens.
    • Verification Libraries:
      • iOS verification uses node-app-attest.
      • Android verification uses @googleapis/playintegrity.
  5. Understand WebBrowser Redirect patterns

    master

    This example demonstrates how to pass information from a website back to an app using the WebBrowser module. This is a standard pattern for authentication flows.

    Key Concepts:

    • Security: Using WebBrowser (powered by SFSafariViewController/SFAuthenticationSession on iOS and Chrome Custom Tabs on Android) is more secure than a WebView because developers cannot inject code. Apple requires SFSafariAuthenticationSession (via WebBrowser.openAuthSessionAsync) for authentication.
    • Session Sharing: Web browser authentication sessions share cookies with the device's default browser (Safari or Chrome), allowing users to stay logged in.
    • Data Retrieval: To get data back from the browser, the website must explicitly redirect to the app's deep link URL containing the data. The app then extracts this data using WebBrowser.openAuthSessionAsync or WebBrowser.openBrowserAsync.
  6. Understand the Satori Example project structure

    master

    The Satori example uses the following file structure to generate and display images:

    • app/api/icon/[icon]+api.ts: An Expo API Route that uses Satori to generate images from React components on the server.
    • app/index.tsx: A client-side screen that fetches and displays the images generated by the API Route.
  7. Update the GraphQL schema

    master

    When you modify your GraphQL server code (e.g., adding a new resolver in src/app/api/graphql+api.ts), you must refetch the schema to keep your local definitions in sync.

    Note: The local development server must be running via npx expo start when executing this command so the introspection query can reach the endpoint.

    npm run sync:schema
  8. Set up the Magic Example

    master

    To run the Magic Example locally, follow these steps:

    1. Install dependencies using yarn or npm install.
    2. Create a new account and app on Magic.link to obtain a publishable key.
    3. Open App.js and replace the MAGIC_KEY placeholder with your actual publishable key.
    4. Start the development server by running yarn start or npm run start.