├── .env.example ├── .eslintrc.cjs ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ └── ci.yml ├── .gitignore ├── .npmrc ├── .prettierrc.cjs ├── .vscode ├── extensions.json └── settings.json ├── README.md ├── apps ├── expo │ ├── .expo-shared │ │ └── assets.json │ ├── app.config.ts │ ├── assets │ │ └── icon.png │ ├── babel.config.js │ ├── expo-plugins │ │ └── with-modify-gradle.js │ ├── index.ts │ ├── metro.config.js │ ├── package.json │ ├── src │ │ ├── _app.tsx │ │ ├── components │ │ │ └── SignInWithOAuth.tsx │ │ ├── hooks │ │ │ └── useWarmUpBrowser.ts │ │ ├── screens │ │ │ ├── home.tsx │ │ │ └── signin.tsx │ │ ├── types │ │ │ └── nativewind.d.ts │ │ └── utils │ │ │ ├── cache.ts │ │ │ └── trpc.tsx │ ├── tailwind.config.cjs │ └── tsconfig.json └── nextjs │ ├── .eslintrc.cjs │ ├── README.md │ ├── next-env.d.ts │ ├── next.config.mjs │ ├── package-lock.json │ ├── package.json │ ├── postcss.config.cjs │ ├── public │ └── favicon.ico │ ├── src │ ├── env │ │ ├── client.mjs │ │ ├── schema.mjs │ │ └── server.mjs │ ├── middleware.ts │ ├── pages │ │ ├── _app.tsx │ │ ├── api │ │ │ └── trpc │ │ │ │ └── [trpc].ts │ │ ├── index.tsx │ │ ├── sign-in │ │ │ └── [[...index]].tsx │ │ └── sign-up │ │ │ └── [[...index]].tsx │ ├── styles │ │ └── globals.css │ └── utils │ │ └── trpc.ts │ ├── tailwind.config.cjs │ └── tsconfig.json ├── package.json ├── packages ├── api │ ├── index.ts │ ├── package.json │ ├── src │ │ ├── context.ts │ │ ├── router │ │ │ ├── auth.ts │ │ │ ├── index.ts │ │ │ └── post.ts │ │ └── trpc.ts │ ├── transformer.ts │ └── tsconfig.json ├── config │ └── tailwind │ │ ├── index.js │ │ ├── package.json │ │ └── postcss.js └── db │ ├── index.ts │ ├── package.json │ ├── prisma │ └── schema.prisma │ └── tsconfig.json ├── patches └── react-native@0.70.5.patch ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── tsconfig.json └── turbo.json /.env.example: -------------------------------------------------------------------------------- 1 | # Since .env is gitignored, you can use .env.example to build a new `.env` file when you clone the repo. 2 | # Keep this file up-to-date when you add new variables to \`.env\`. 3 | 4 | # This file will be committed to version control, so make sure not to have any secrets in it. 5 | # If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets. 6 | 7 | # We use dotenv to load Prisma from Next.js' .env file 8 | # @see https://www.prisma.io/docs/reference/database-reference/connection-urls 9 | DATABASE_URL=file:./db.sqlite 10 | 11 | # CLERK is used for authentication and authorization in the app 12 | # @see https://dashboard.clerk.dev for your Clerk API keys 13 | # 14 | ### NEW KEYS FOR APPS AFTER 1/18/2023 15 | NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXXXXXX 16 | CLERK_SECRET_KEY=sk_test_XXXXXXXXXXXXXXXXXXXXXXXX 17 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import("eslint").Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | parser: "@typescript-eslint/parser", 5 | parserOptions: { 6 | tsconfigRootDir: __dirname, 7 | project: [ 8 | "./tsconfig.json", 9 | "./apps/*/tsconfig.json", 10 | "./packages/*/tsconfig.json", 11 | ], 12 | }, 13 | plugins: ["@typescript-eslint"], 14 | extends: ["plugin:@typescript-eslint/recommended"], 15 | }; 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Logs** 24 | Please provide logs showing the error. 25 | 26 | **Screenshots** 27 | If applicable, add screenshots to help explain your problem. 28 | 29 | **Desktop (please complete the following information):** 30 | - OS: [e.g. iOS] 31 | - Browser [e.g. chrome, safari] 32 | - Version [e.g. 22] 33 | 34 | **Smartphone (please complete the following information):** 35 | - Device: [e.g. iPhone6] 36 | - OS: [e.g. iOS8.1] 37 | - Browser [e.g. stock browser, safari] 38 | - Version [e.g. 22] 39 | 40 | **Additional context** 41 | Add any other context about the problem here. 42 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | branches: ["*"] 6 | push: 7 | branches: ["main"] 8 | 9 | # You can leverage Vercel Remote Caching with Turbo to speed up your builds 10 | # @link https://turborepo.org/docs/core-concepts/remote-caching#remote-caching-on-vercel-builds 11 | env: 12 | TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} 13 | TURBO_TEAM: ${{ secrets.TURBO_TEAM }} 14 | NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}} 15 | CLERK_SECRET_KEY: ${{secrets.CLERK_SECRET_KEY}} 16 | 17 | 18 | jobs: 19 | build-lint: 20 | env: 21 | DATABASE_URL: file:./db.sqlite 22 | runs-on: ubuntu-latest 23 | 24 | steps: 25 | - name: Checkout repo 26 | uses: actions/checkout@v3 27 | 28 | - name: Setup pnpm 29 | uses: pnpm/action-setup@v2.2.4 30 | 31 | - name: Setup Node 18 32 | uses: actions/setup-node@v3 33 | with: 34 | node-version: 18 35 | 36 | - name: Get pnpm store directory 37 | id: pnpm-cache 38 | run: | 39 | echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT 40 | 41 | - name: Setup pnpm cache 42 | uses: actions/cache@v3 43 | with: 44 | path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} 45 | key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} 46 | restore-keys: | 47 | ${{ runner.os }}-pnpm-store- 48 | 49 | - name: Install deps (with cache) 50 | run: pnpm install 51 | 52 | - name: Next.js cache 53 | uses: actions/cache@v3 54 | with: 55 | path: ${{ github.workspace }}apps/nextjs/.next/cache 56 | key: ${{ runner.os }}-${{ runner.node }}-${{ hashFiles('**/pnpm-lock.yaml') }}-nextjs 57 | 58 | - name: Build, lint and type-check 59 | run: pnpm turbo build lint type-check 60 | 61 | - name: Check workspaces 62 | run: pnpm manypkg check 63 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | .pnp 6 | .pnp.js 7 | 8 | # testing 9 | coverage 10 | 11 | # database 12 | prisma/db.sqlite 13 | prisma/db.sqlite-journal 14 | 15 | # next.js 16 | .next/ 17 | out/ 18 | 19 | # expo 20 | .expo/ 21 | dist/ 22 | 23 | # production 24 | build 25 | 26 | # misc 27 | .DS_Store 28 | *.pem 29 | 30 | # debug 31 | npm-debug.log* 32 | yarn-debug.log* 33 | yarn-error.log* 34 | .pnpm-debug.log* 35 | 36 | # local env files 37 | .env 38 | .env*.local 39 | 40 | # vercel 41 | .vercel 42 | 43 | # typescript 44 | *.tsbuildinfo 45 | 46 | # turbo 47 | .turbo 48 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | # Expo doesn't play nice with pnpm by default. 2 | # The symbolic links of pnpm break the rules of Expo monorepos. 3 | # @link https://docs.expo.dev/guides/monorepos/#common-issues 4 | node-linker=hoisted 5 | 6 | # In order to cache Prisma correctly 7 | public-hoist-pattern[]=*prisma* 8 | 9 | # FIXME: @prisma/client is required by the @acme/auth, 10 | # but we don't want it installed there since it's already 11 | # installed in the @acme/db package 12 | strict-peer-dependencies=false 13 | -------------------------------------------------------------------------------- /.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import("prettier").Config} */ 2 | module.exports = { 3 | arrowParens: "always", 4 | printWidth: 80, 5 | singleQuote: false, 6 | jsxSingleQuote: false, 7 | semi: true, 8 | trailingComma: "all", 9 | tabWidth: 2, 10 | plugins: [require.resolve("prettier-plugin-tailwindcss")], 11 | tailwindConfig: "./packages/config/tailwind", 12 | }; 13 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "esbenp.prettier-vscode", 4 | "dbaeumer.vscode-eslint", 5 | "bradlc.vscode-tailwindcss", 6 | "Prisma.prisma" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.codeActionsOnSave": { 3 | "source.fixAll.eslint": true 4 | }, 5 | "editor.defaultFormatter": "esbenp.prettier-vscode", 6 | "editor.formatOnSave": true, 7 | "eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }], 8 | "typescript.tsdk": "node_modules/typescript/lib" 9 | } 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![CI](https://github.com/perkinsjr/t3-turbo-and-clerk/actions/workflows/ci.yml/badge.svg)](https://github.com/perkinsjr/t3-turbo-and-clerk/actions/workflows/ci.yml) 2 | 3 | # Create T3 Turbo with Clerk Authentication 4 | 5 | ## Clerk Dashboard Setup 6 | 7 | For this template to work you need to enable Discord as an OAuth provider. You can find the social options under `User & Authentication / Social Providers` in the [Clerk Dashboard](https://dashboard.clerk.dev) 8 | 9 | > If you change any setting here outside of adding Discord, you may need to update your Expo code to handle any requirements you change. 10 | 11 | It uses [Turborepo](https://turborepo.org/) and contains: 12 | 13 | ## Code Layout 14 | 15 | ``` 16 | .github 17 | └─ workflows 18 | └─ CI with pnpm cache setup 19 | .vscode 20 | └─ Recommended extensions and settings for VSCode users 21 | apps 22 | ├─ expo 23 | └─ next.js 24 | ├─ Next.js 13 25 | ├─ React 18 26 | └─ E2E Typesafe API Server & Client 27 | packages 28 | ├─ api 29 | | └─ tRPC v10 router definition 30 | └─ db 31 | └─ typesafe db-calls using Prisma 32 | ``` 33 | 34 | ## Quick Start 35 | 36 | To get it running, follow the steps below: 37 | 38 | ### Setup dependencies 39 | 40 | ```diff 41 | # Install dependencies 42 | pnpm i 43 | 44 | 45 | # Configure environment variables. 46 | # There is an `.env.example` in the root directory you can use for reference 47 | cp .env.example .env 48 | 49 | # Push the Prisma schema to your database 50 | pnpm db-push 51 | ``` 52 | 53 | ### Configure Expo app 54 | 55 | Expo doesn't use the .env for the publishable key, so you will need to go to `apps/expo/app.config.ts` and add it there. 56 | 57 | ``` 58 | const CLERK_PUBLISHABLE_KEY = "your-clerk-publishable-key"; 59 | 60 | ``` 61 | 62 | ### Configure Expo `dev`-script 63 | 64 | > **Note:** If you want to use a physical phone with Expo Go, just run `pnpm dev` and scan the QR-code. 65 | 66 | #### Use iOS Simulator 67 | 68 | 1. Make sure you have XCode and XCommand Line Tools installed [as shown on expo docs](https://docs.expo.dev/workflow/ios-simulator/). 69 | 2. Change the `dev` script at `apps/expo/package.json` to open the iOS simulator. 70 | 71 | ```diff 72 | + "dev": "expo start --ios", 73 | ``` 74 | 75 | 3. Run `pnpm dev` at the project root folder. 76 | 77 | #### For Android 78 | 79 | 1. Install Android Studio tools [as shown on expo docs](https://docs.expo.dev/workflow/android-studio-emulator/). 80 | 2. Change the `dev` script at `apps/expo/package.json` to open the Android emulator. 81 | 82 | ```diff 83 | + "dev": "expo start --android", 84 | ``` 85 | 86 | 3. Run `pnpm dev` at the project root folder. 87 | 88 | ## Deployment 89 | 90 | ### Next.js 91 | 92 | > Note if you are building locallly you will need to insert your env correctly, for example using `pnpm with-env next build` 93 | 94 | #### Prerequisites 95 | 96 | _We do not recommend deploying a SQLite database on serverless environments since the data wouldn't be persisted. I provisioned a quick Postgresql database on [Railway](https://railway.app), but you can of course use any other database provider. Make sure the prisma schema is updated to use the correct database._ 97 | 98 | #### Deploy to Vercel 99 | 100 | Let's deploy the Next.js application to [Vercel](https://vercel.com/). If you have ever deployed a Turborepo app there, the steps are quite straightforward. You can also read the [official Turborepo guide](https://vercel.com/docs/concepts/monorepos/turborepo) on deploying to Vercel. 101 | 102 | 1. Create a new project on Vercel, select the `apps/nextjs` folder as the root directory and apply the following build settings: 103 | 104 | Vercel deployment settings 105 | 106 | > The install command filters out the expo package and saves a few second (and cache size) of dependency installation. The build command makes us build the application using Turbo. 107 | 108 | 2. Add your `DATABASE_URL`,`NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` and `CLERK_SECRET_KEY` environment variable. 109 | 110 | 3. Done! Your app should successfully deploy. Assign your domain and use that instead of `localhost` for the `url` in the Expo app so that your Expo app can communicate with your backend when you are not in development. 111 | 112 | ### Expo 113 | 114 | Deploying your Expo application works slightly differently compared to Next.js on the web. Instead of "deploying" your app online, you need to submit production builds of your app to the app stores, like [Apple App Store](https://www.apple.com/app-store/) and [Google Play](https://play.google.com/store/apps). You can read the full [Distributing your app](https://docs.expo.dev/distribution/introduction/), including best practices, in the Expo docs. 115 | 116 | 1. Let's start by setting up [EAS Build](https://docs.expo.dev/build/introduction/), which is short for Expo Application Services. The build service helps you create builds of your app, without requiring a full native development setup. The commands below are a summary of [Creating your first build](https://docs.expo.dev/build/setup/). 117 | 118 | ```bash 119 | // Install the EAS CLI 120 | $ pnpm add -g eas-cli 121 | 122 | // Log in with your Expo account 123 | $ eas login 124 | 125 | // Configure your Expo app 126 | $ cd apps/expo 127 | $ eas build:configure 128 | ``` 129 | 130 | 2. After the initial setup, you can create your first build. You can build for Android and iOS platforms and use different [**eas.json** build profiles](https://docs.expo.dev/build-reference/eas-json/) to create production builds or development, or test builds. Let's make a production build for iOS. 131 | 132 | ``` 133 | $ eas build --platform ios --profile production 134 | ``` 135 | 136 | > If you don't specify the `--profile` flag, EAS uses the `production` profile by default. 137 | 138 | 3. Now that you have your first production build, you can submit this to the stores. [EAS Submit](https://docs.expo.dev/submit/introduction/) can help you send the build to the stores. 139 | 140 | ``` 141 | $ eas submit --platform ios --latest 142 | ``` 143 | 144 | > You can also combine build and submit in a single command, using `eas build ... --auto-submit`. 145 | 146 | 4. Before you can get your app in the hands of your users, you'll have to provide additional information to the app stores. This includes screenshots, app information, privacy policies, etc. _While still in preview_, [EAS Metadata](https://docs.expo.dev/eas/metadata/) can help you with most of this information. 147 | 148 | 5. If you're using OAuth social providers with Clerk, for instance Google, Apple, Facebook, etc..., you must whitelist your own OAuth redirect URL for the Expo application in the Clerk Dashboard. 149 | 150 | In `apps/expo/app.config.ts`, add a `scheme` that will be used to identify your standalone app. 151 | 152 | ```ts 153 | import { ExpoConfig, ConfigContext } from "@expo/config"; 154 | 155 | const CLERK_PUBLISHABLE_KEY = "your-clerk-publishable-key"; 156 | 157 | const defineConfig = (_ctx: ConfigContext): ExpoConfig => ({ 158 | name: "expo", 159 | slug: "expo", 160 | scheme: "your-app-scheme", 161 | // ... 162 | }); 163 | ``` 164 | 165 | Then, in the [Clerk Dashboard](https://dashboard.clerk.dev/), go to **User & Authentication > Social Connections > Settings** and add your app's scheme and redirect URL to the **Redirect URLs** field: 166 | 167 | ```txt 168 | your-app-scheme://oauth-native-callback 169 | ``` 170 | 171 | Here, `your-app-scheme` corresponds to the `scheme` defined in `app.config.ts`, and `oauth-native-callback` corresponds to the redirect URL defined when authenticating with social providers. See [SignInWithOAuth.tsx](/apps/expo/src/components/SignInWithOAuth.tsx) for reference. 172 | 173 | > You can find more information about this in the [Expo documentation](https://docs.expo.dev/versions/latest/sdk/auth-session/#redirecting-to-your-app). 174 | 175 | You should now be able to sign in with your social providers in the TestFlight application build. 176 | 177 | 6. Once everything is approved, your users can finally enjoy your app. Let's say you spotted a small typo; you'll have to create a new build, submit it to the stores, and wait for approval before you can resolve this issue. In these cases, you can use EAS Update to quickly send a small bugfix to your users without going through this long process. Let's start by setting up EAS Update. 178 | 179 | The steps below summarize the [Getting started with EAS Update](https://docs.expo.dev/eas-update/getting-started/#configure-your-project) guide. 180 | 181 | ```bash 182 | // Add the `expo-updates` library to your Expo app 183 | $ cd apps/expo 184 | $ pnpm expo install expo-updates 185 | 186 | // Configure EAS Update 187 | $ eas update:configure 188 | ``` 189 | 190 | 6. Before we can send out updates to your app, you have to create a new build and submit it to the app stores. For every change that includes native APIs, you have to rebuild the app and submit the update to the app stores. See steps 2 and 3. 191 | 192 | 7. Now that everything is ready for updates, let's create a new update for `production` builds. With the `--auto` flag, EAS Update uses your current git branch name and commit message for this update. See [How EAS Update works](https://docs.expo.dev/eas-update/how-eas-update-works/#publishing-an-update) for more information. 193 | 194 | ```bash 195 | $ cd apps/expo 196 | $ eas update --auto 197 | ``` 198 | 199 | > Your OTA (Over The Air) updates must always follow the app store's rules. You can't change your app's primary functionality without getting app store approval. But this is a fast way to update your app for minor changes and bug fixes. 200 | 201 | 8. Done! Now that you have created your production build, submitted it to the stores, and installed EAS Update, you are ready for anything! 202 | 203 | ## References 204 | 205 | The stack originates from [create-t3-turbo](https://github.com/t3-oss/create-t3-turbo). 206 | -------------------------------------------------------------------------------- /apps/expo/.expo-shared/assets.json: -------------------------------------------------------------------------------- 1 | { 2 | "12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true, 3 | "40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true 4 | } 5 | -------------------------------------------------------------------------------- /apps/expo/app.config.ts: -------------------------------------------------------------------------------- 1 | import { ExpoConfig, ConfigContext } from "@expo/config"; 2 | 3 | const CLERK_PUBLISHABLE_KEY = "your-clerk-publishable-key"; 4 | 5 | const defineConfig = (_ctx: ConfigContext): ExpoConfig => ({ 6 | name: "expo", 7 | slug: "expo", 8 | version: "1.0.0", 9 | orientation: "portrait", 10 | icon: "./assets/icon.png", 11 | userInterfaceStyle: "light", 12 | splash: { 13 | image: "./assets/icon.png", 14 | resizeMode: "contain", 15 | backgroundColor: "#2e026d", 16 | }, 17 | updates: { 18 | fallbackToCacheTimeout: 0, 19 | }, 20 | assetBundlePatterns: ["**/*"], 21 | ios: { 22 | supportsTablet: true, 23 | bundleIdentifier: "your.bundle.identifier", 24 | }, 25 | android: { 26 | adaptiveIcon: { 27 | foregroundImage: "./assets/icon.png", 28 | backgroundColor: "#2e026d", 29 | }, 30 | }, 31 | extra: { 32 | eas: { 33 | projectId: "your-project-id", 34 | }, 35 | CLERK_PUBLISHABLE_KEY, 36 | }, 37 | plugins: ["./expo-plugins/with-modify-gradle.js"], 38 | }); 39 | 40 | export default defineConfig; 41 | -------------------------------------------------------------------------------- /apps/expo/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/clerk/t3-turbo-and-clerk/a23a2cdf6c6e2e2a0e5665d49fcbdfdf1abafe86/apps/expo/assets/icon.png -------------------------------------------------------------------------------- /apps/expo/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function (api) { 2 | api.cache(true); 3 | return { 4 | plugins: ["nativewind/babel"], 5 | presets: ["babel-preset-expo"], 6 | }; 7 | }; 8 | -------------------------------------------------------------------------------- /apps/expo/expo-plugins/with-modify-gradle.js: -------------------------------------------------------------------------------- 1 | //@ts-check 2 | 3 | // This plugin is required for fixing `.apk` build issue 4 | // It appends Expo and RN versions into the `build.gradle` file 5 | // References: 6 | // https://github.com/t3-oss/create-t3-turbo/issues/120 7 | // https://github.com/expo/expo/issues/18129 8 | 9 | const { withProjectBuildGradle } = require("@expo/config-plugins"); 10 | 11 | module.exports = (config) => { 12 | return withProjectBuildGradle(config, (config) => { 13 | if (!config.modResults.contents.includes("ext.getPackageJsonVersion =")) { 14 | config.modResults.contents = config.modResults.contents.replace( 15 | "buildscript {", 16 | `buildscript { 17 | ext.getPackageJsonVersion = { packageName -> 18 | new File(['node', '--print', "JSON.parse(require('fs').readFileSync(require.resolve('\${packageName}/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) 19 | }`, 20 | ); 21 | } 22 | 23 | if (!config.modResults.contents.includes("reactNativeVersion =")) { 24 | config.modResults.contents = config.modResults.contents.replace( 25 | "ext {", 26 | `ext { 27 | reactNativeVersion = "\${ext.getPackageJsonVersion('react-native')}"`, 28 | ); 29 | } 30 | 31 | if (!config.modResults.contents.includes("expoPackageVersion =")) { 32 | config.modResults.contents = config.modResults.contents.replace( 33 | "ext {", 34 | `ext { 35 | expoPackageVersion = "\${ext.getPackageJsonVersion('expo')}"`, 36 | ); 37 | } 38 | 39 | return config; 40 | }); 41 | }; 42 | -------------------------------------------------------------------------------- /apps/expo/index.ts: -------------------------------------------------------------------------------- 1 | import { registerRootComponent } from "expo"; 2 | 3 | import { App } from "./src/_app"; 4 | 5 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App); 6 | // It also ensures that whether you load the app in Expo Go or in a native build, 7 | // the environment is set up appropriately 8 | registerRootComponent(App); 9 | -------------------------------------------------------------------------------- /apps/expo/metro.config.js: -------------------------------------------------------------------------------- 1 | // Learn more: https://docs.expo.dev/guides/monorepos/ 2 | // eslint-disable-next-line @typescript-eslint/no-var-requires 3 | const { getDefaultConfig } = require('expo/metro-config'); 4 | // eslint-disable-next-line @typescript-eslint/no-var-requires 5 | const path = require('path'); 6 | 7 | const projectRoot = __dirname; 8 | const workspaceRoot = path.resolve(projectRoot, '../..'); 9 | 10 | // Create the default Metro config 11 | const config = getDefaultConfig(projectRoot); 12 | 13 | // Add the additional `cjs` extension to the resolver 14 | config.resolver.sourceExts.push('cjs'); 15 | 16 | // 1. Watch all files within the monorepo 17 | config.watchFolders = [workspaceRoot]; 18 | // 2. Let Metro know where to resolve packages and in what order 19 | config.resolver.nodeModulesPaths = [ 20 | path.resolve(projectRoot, 'node_modules'), 21 | path.resolve(workspaceRoot, 'node_modules'), 22 | ]; 23 | // 3. Force Metro to resolve (sub)dependencies only from the `nodeModulesPaths` 24 | config.resolver.disableHierarchicalLookup = true; 25 | 26 | module.exports = config; 27 | -------------------------------------------------------------------------------- /apps/expo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@acme/expo", 3 | "version": "0.1.0", 4 | "main": "index.ts", 5 | "scripts": { 6 | "start": "expo start", 7 | "dev": "expo start", 8 | "clean": "rm -rf .expo .turbo node_modules", 9 | "android": "expo start --android", 10 | "ios": "expo start --ios", 11 | "web": "expo start --web", 12 | "lint": "eslint . --ext ts,tsx" 13 | }, 14 | "dependencies": { 15 | "@acme/api": "*", 16 | "@acme/tailwind-config": "*", 17 | "@clerk/clerk-expo": "^0.17.7", 18 | "@shopify/flash-list": "^1.4.0", 19 | "@tanstack/react-query": "^4.16.1", 20 | "@trpc/client": "^10.1.0", 21 | "@trpc/react-query": "^10.1.0", 22 | "@trpc/server": "^10.1.0", 23 | "expo": "^48.0.6", 24 | "expo-auth-session": "^4.0.3", 25 | "expo-random": "^13.0.0", 26 | "expo-secure-store": "^12.1.1", 27 | "expo-status-bar": "^1.4.2", 28 | "expo-web-browser": "^12.1.1", 29 | "nativewind": "^2.0.11", 30 | "react": "18.2.0", 31 | "react-dom": "18.2.0", 32 | "react-native": "0.70.5", 33 | "react-native-safe-area-context": "4.4.1", 34 | "react-native-web": "~0.18.10" 35 | }, 36 | "devDependencies": { 37 | "@babel/core": "^7.19.3", 38 | "@babel/preset-env": "^7.19.3", 39 | "@babel/runtime": "^7.19.0", 40 | "@types/react": "^18.0.25", 41 | "@types/react-native": "~0.70.6", 42 | "eslint": "^8.28.0", 43 | "postcss": "^8.4.19", 44 | "tailwindcss": "^3.2.4", 45 | "typescript": "^4.9.3" 46 | }, 47 | "private": true 48 | } 49 | -------------------------------------------------------------------------------- /apps/expo/src/_app.tsx: -------------------------------------------------------------------------------- 1 | import { StatusBar } from "expo-status-bar"; 2 | import React from "react"; 3 | import { SafeAreaProvider } from "react-native-safe-area-context"; 4 | import { TRPCProvider } from "./utils/trpc"; 5 | 6 | import { HomeScreen } from "./screens/home"; 7 | import { SignInSignUpScreen } from "./screens/signin"; 8 | import { ClerkProvider, SignedIn, SignedOut } from "@clerk/clerk-expo"; 9 | import { tokenCache } from "./utils/cache"; 10 | import Constants from "expo-constants"; 11 | 12 | export const App = () => { 13 | return ( 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | ); 31 | }; 32 | -------------------------------------------------------------------------------- /apps/expo/src/components/SignInWithOAuth.tsx: -------------------------------------------------------------------------------- 1 | import { useOAuth } from "@clerk/clerk-expo"; 2 | import React from "react"; 3 | import { Button, View } from "react-native"; 4 | import { useWarmUpBrowser } from "../hooks/useWarmUpBrowser"; 5 | 6 | const SignInWithOAuth = () => { 7 | useWarmUpBrowser(); 8 | 9 | const { startOAuthFlow } = useOAuth({ strategy: "oauth_discord" }); 10 | 11 | const handleSignInWithDiscordPress = React.useCallback(async () => { 12 | try { 13 | const { createdSessionId, signIn, signUp, setActive } = 14 | await startOAuthFlow(); 15 | if (createdSessionId) { 16 | setActive?.({ session: createdSessionId }); 17 | } else { 18 | // Modify this code to use signIn or signUp to set this missing requirements you set in your dashboard. 19 | throw new Error("There are unmet requirements, modifiy this else to handle them") 20 | 21 | } 22 | } catch (err) { 23 | console.log(JSON.stringify(err, null, 2)); 24 | console.log("error signing in", err); 25 | } 26 | }, []); 27 | 28 | return ( 29 | 30 |