• Stars
    star
    1,022
  • Rank 45,039 (Top 0.9 %)
  • Language
    TypeScript
  • Created almost 2 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A t3 Turbo starter with Clerk as the auth provider.

CI

Create T3 Turbo with Clerk Authentication

Clerk Dashboard Setup

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

If you change any setting here outside of adding Discord, you may need to update your Expo code to handle any requirements you change.

It uses Turborepo and contains:

Code Layout

.github
  └─ workflows
        └─ CI with pnpm cache setup
.vscode
  └─ Recommended extensions and settings for VSCode users
apps
  ├─ expo
  └─ next.js
      ├─ Next.js 13
      ├─ React 18
      └─ E2E Typesafe API Server & Client
packages
 ├─ api
 |   └─ tRPC v10 router definition
 └─ db
     └─ typesafe db-calls using Prisma

Quick Start

To get it running, follow the steps below:

Setup dependencies

# Install dependencies
pnpm i


# Configure environment variables.
# There is an `.env.example` in the root directory you can use for reference
cp .env.example .env

# Push the Prisma schema to your database
pnpm db-push

Configure Expo app

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.

const CLERK_PUBLISHABLE_KEY = "your-clerk-publishable-key";

Configure Expo dev-script

Note: If you want to use a physical phone with Expo Go, just run pnpm dev and scan the QR-code.

Use iOS Simulator

  1. Make sure you have XCode and XCommand Line Tools installed as shown on expo docs.
  2. Change the dev script at apps/expo/package.json to open the iOS simulator.
+  "dev": "expo start --ios",
  1. Run pnpm dev at the project root folder.

For Android

  1. Install Android Studio tools as shown on expo docs.
  2. Change the dev script at apps/expo/package.json to open the Android emulator.
+  "dev": "expo start --android",
  1. Run pnpm dev at the project root folder.

Deployment

Next.js

Note if you are building locallly you will need to insert your env correctly, for example using pnpm with-env next build

Prerequisites

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, but you can of course use any other database provider. Make sure the prisma schema is updated to use the correct database.

Deploy to Vercel

Let's deploy the Next.js application to Vercel. If you have ever deployed a Turborepo app there, the steps are quite straightforward. You can also read the official Turborepo guide on deploying to Vercel.

  1. Create a new project on Vercel, select the apps/nextjs folder as the root directory and apply the following build settings:

Vercel deployment settings

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.

  1. Add your DATABASE_URL,NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY environment variable.

  2. 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.

Expo

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 and Google Play. You can read the full Distributing your app, including best practices, in the Expo docs.

  1. Let's start by setting up EAS Build, 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.

    // Install the EAS CLI
    $ pnpm add -g eas-cli
    
    // Log in with your Expo account
    $ eas login
    
    // Configure your Expo app
    $ cd apps/expo
    $ eas build:configure
  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 to create production builds or development, or test builds. Let's make a production build for iOS.

    $ eas build --platform ios --profile production
    

    If you don't specify the --profile flag, EAS uses the production profile by default.

  3. Now that you have your first production build, you can submit this to the stores. EAS Submit can help you send the build to the stores.

    $ eas submit --platform ios --latest
    

    You can also combine build and submit in a single command, using eas build ... --auto-submit.

  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 can help you with most of this information.

  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.

    In apps/expo/app.config.ts, add a scheme that will be used to identify your standalone app.

    import { ExpoConfig, ConfigContext } from "@expo/config";
    
    const CLERK_PUBLISHABLE_KEY = "your-clerk-publishable-key";
    
    const defineConfig = (_ctx: ConfigContext): ExpoConfig => ({
       name: "expo",
       slug: "expo",
       scheme: "your-app-scheme",
       // ...
    });

    Then, in the Clerk Dashboard, go to User & Authentication > Social Connections > Settings and add your app's scheme and redirect URL to the Redirect URLs field:

    your-app-scheme://oauth-native-callback

    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 for reference.

    You can find more information about this in the Expo documentation.

    You should now be able to sign in with your social providers in the TestFlight application build.

  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.

    The steps below summarize the Getting started with EAS Update guide.

    // Add the `expo-updates` library to your Expo app
    $ cd apps/expo
    $ pnpm expo install expo-updates
    
    // Configure EAS Update
    $ eas update:configure
  7. 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.

  8. 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 for more information.

    $ cd apps/expo
    $ eas update --auto

    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.

  9. Done! Now that you have created your production build, submitted it to the stores, and installed EAS Update, you are ready for anything!

References

The stack originates from create-t3-turbo.

More Repositories

1

javascript

Official Javascript repository for Clerk authentication
TypeScript
1,082
star
2

clerk-nextjs-demo-app-router

Auth starts here with the official Next.js starter utilizing the app directory
TypeScript
213
star
3

use-stripe-subscription

TypeScript
134
star
4

clerk-nextjs-starter

Official starter repo for Clerk and Next.js
JavaScript
114
star
5

clerk-nextjs-app-quickstart

The official companion repo for Clerk's Next.js Quickstart using the app router
TypeScript
108
star
6

clerk-docs

The documentation content for Clerk, an authentication and user management platform.
JavaScript
100
star
7

clerk-expo-starter

Expo starter project using Clerk for authentication
TypeScript
93
star
8

clerk-sdk-go

Access the Clerk Backend API from Go
Go
85
star
9

clerk-nextjs-examples

Official Clerk.dev Next.js examples repository. See how you can build all kinds of forms using Clerk!
76
star
10

organizations-demo

TypeScript
57
star
11

remix-bossa-nova-stack

The Remix Stack with Clerk authentication, Supabase database, Chakra UI, testing, linting, and more.
JavaScript
51
star
12

remix-auth-starter

Add sign up, sign in, profile management, and authenticated API routes to your Remix application with the Remix Auth Starter by Clerk.
TypeScript
38
star
13

clerk-ios

Clerk helps developers build user management. We provide streamlined user experiences for your users to sign up, sign in, and manage their profile.
Swift
35
star
14

clerk-chrome-extension-starter

This starter project shows how to use Clerk authentication in a React based Chrome Extension.
TypeScript
32
star
15

migration-script

TypeScript
29
star
16

clerk-react-demo

Example starter repo for Clerk and React
TypeScript
27
star
17

playwright-e2e-template

Playwright End to End testing suite template
TypeScript
26
star
18

clerk-nextjs-onboarding-sample-app

TypeScript
26
star
19

clerk-fastify-react-prisma-starter

Clerk Fastify React Prisma fullstack monorepo starter
TypeScript
26
star
20

clerk-sdk-python

Python
24
star
21

clerk-sdk-ruby

Access the Clerk Backend API from Ruby
Ruby
24
star
22

use-stripe-subscription-demo

TypeScript
23
star
23

clerk-supabase

Demo todo app built with Next.js, Supabase, and Clerk
JavaScript
22
star
24

clerk-prisma-starter

Official Clerk-Prisma starter project
TypeScript
22
star
25

clerk-nextjs-pages-quickstart

The official companion repo for Clerk's Next.js Quickstart using the pages router
TypeScript
22
star
26

clerk-javascript-quickstart

The official companion repo for Clerk's JavaScript Quickstart
JavaScript
15
star
27

clerk-hasura-starter

Official starter repo for Clerk and Hasura
JavaScript
14
star
28

clerk-react-quickstart

CSS
14
star
29

clerk-firebase-starter

Official guide on how to use Clerk.dev with Firebase
TypeScript
13
star
30

clerk-playwright-nextjs

An example repository for E2E testing with Clerk + Nextjs + Playwright
TypeScript
11
star
31

clerk-react-examples

Official Clerk.dev React examples repository. See how you can build all kinds of forms using Clerk!
11
star
32

clerk-nextjs-demo-pages-router

Auth starts here with the official Next.js demo utilizing the pages directory.
TypeScript
10
star
33

clerk-rails-starter

Official guide on how to use Clerk.dev with Rails
Ruby
10
star
34

clerk-fastify-quickstart

Official starter repo for Clerk and Fastify
TypeScript
10
star
35

clerk-sdk-java

Java
10
star
36

clerk-remix-quickstart

Learn how to use Clerk to quickly add secure authentication and user management to your Remix application. This repo assumed you are using Remix v2 or later
TypeScript
9
star
37

clerk-gatsby-starter

Official guide on how to use Clerk.dev with Gatsby
CSS
9
star
38

clerk-astro-quickstart

Astro
8
star
39

edge-demo

Authentication at Edge with Clerk+Next.js
JavaScript
8
star
40

clerk-next-app-router-starter

Get Started with Clerk and Next.js App Router
TypeScript
8
star
41

django-example

Python
8
star
42

clerk-sdk-node

Access the Clerk Backend API from Node.js
TypeScript
7
star
43

clerk-supabase-starter

Example starter repo for Clerk and Supabase
JavaScript
7
star
44

clerk-expo-quickstart

The official companion repo for Clerk's Expo Quickstart
TypeScript
6
star
45

docs

Clerk official docs powered by Gitbook
Go
6
star
46

clerk-redwood-starter

Example starter repo for Clerk and RedwoodJS
TypeScript
6
star
47

clerk-nextjs-multi-domain-example

TypeScript
6
star
48

nextjs-context-example

JavaScript
6
star
49

nextjs-clerk-airtable-stripe-starter

Next.js + Clerk + Airtable + Stripe starter
TypeScript
6
star
50

clerk-supabase-nextjs

The official companion repo for Clerk's Supabase integration guide
TypeScript
5
star
51

clerk-playground

Explore the features provided by Clerk in building authentication and user management flows
JavaScript
4
star
52

multi-domain-test

Playground for internally testing the multi domain and reverse proxy features
TypeScript
4
star
53

clerk-cypress-nextjs

Example repo using Clerk, Cypress and NextJS
TypeScript
4
star
54

clerk-fauna-starter

Example starter repo for Clerk and Fauna
JavaScript
3
star
55

clerk-tanstack-start-quickstart

Learn how to use Clerk to quickly add secure authentication and user management to your TanStack Start application.
TypeScript
3
star
56

more-cookies-please

Sample codebase for Clerk + Hasura with Next.js tutorial
JavaScript
3
star
57

svix-vercel-revalidate-example

JavaScript
3
star
58

clerk-nextjs-ssr-demo

TypeScript
3
star
59

remix-fauna-tutorial

Sample codebase for Remix, Fauna, and Clerk tutorial
JavaScript
2
star
60

clerk-stripe-sessions-demo

TypeScript
2
star
61

clerk-sso-starter

JavaScript
2
star
62

redwood-tutorial-with-clerk

Sample codebase for RedwoodJS + Clerk tutorial
JavaScript
2
star
63

clerk-capacitor-starter

Capacitor starter project using Clerk for authentication
JavaScript
2
star
64

gatsby-plugin-clerk

Drop-in Clerk integration for Gatsby sites
TypeScript
1
star
65

customizationsandbox

Undocumented and not stable yet, but ready for testing. Typescript highly recommended.
JavaScript
1
star
66

clerk-airtable-apartment-hunt

Official Clerk-Airtable apartment hunt example repository!
TypeScript
1
star
67

clerk-netlify-template

A Clerk Starter with Netlify.
JavaScript
1
star