Giter Club home page Giter Club logo

create-t3-turbo's Introduction

create-t3-turbo

Note Due to high demand, this repo now uses the app directory with some new experimental features. If you want to use the more traditional pages router, check out the repo before the update.

Note OAuth deployments are now working for preview deployments. Read deployment guide and check out the source to learn more!

Installation

There are two ways of initializing an app using the create-t3-turbo starter. You can either use this repository as a template:

use-as-template

or use Turbo's CLI to init your project (use PNPM as package manager):

npx create-turbo@latest -e https://github.com/t3-oss/create-t3-turbo

About

Ever wondered how to migrate your T3 application into a monorepo? Stop right here! This is the perfect starter repo to get you running with the perfect stack!

It uses Turborepo and contains:

.github
  └─ workflows
        └─ CI with pnpm cache setup
.vscode
  └─ Recommended extensions and settings for VSCode users
apps
  ├─ auth-proxy
  |   ├─ Nitro server to proxy OAuth requests in preview deployments
  |   └─ Uses Auth.js Core
  ├─ expo
  |   ├─ Expo SDK 49
  |   ├─ React Native using React 18
  |   ├─ Navigation using Expo Router
  |   ├─ Tailwind using NativeWind
  |   └─ Typesafe API calls using tRPC
  └─ next.js
      ├─ Next.js 14
      ├─ React 18
      ├─ Tailwind CSS
      └─ E2E Typesafe API Server & Client
packages
  ├─ api
  |   └─ tRPC v11 router definition
  ├─ auth
  |   └─ Authentication using next-auth. **NOTE: Only for Next.js app, not Expo**
  ├─ db
  |   └─ Typesafe db calls using Drizzle & Planetscale
  └─ ui
      └─ Start of a UI package for the webapp using shadcn-ui
tooling
  ├─ eslint
  |   └─ shared, fine-grained, eslint presets
  ├─ prettier
  |   └─ shared prettier configuration
  ├─ tailwind
  |   └─ shared tailwind configuration
  └─ typescript
      └─ shared tsconfig you can extend from

In this template, we use @acme as a placeholder for package names. As a user, you might want to replace it with your own organization or project name. You can use find-and-replace to change all the instances of @acme to something like @my-company or @project-name.

Quick Start

Note The db package is preconfigured to use PlanetScale and is edge-bound with the database.js driver. If you're using something else, make the necessary modifications to the schema as well as the client and the drizzle config. If you want to switch to non-edge database driver, remove export const runtime = "edge"; from all pages and api routes.

To get it running, follow the steps below:

1. 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 Drizzle schema to the database
pnpm db:push

2. Configure Expo dev-script

Use iOS Simulator

  1. Make sure you have XCode and XCommand Line Tools installed as shown on expo docs.

    NOTE: If you just installed XCode, or if you have updated it, you need to open the simulator manually once. Run npx expo start in the root dir, and then enter I to launch Expo Go. After the manual launch, you can run pnpm dev in the root directory.

    +  "dev": "expo start --ios",
  2. Run pnpm dev at the project root folder.

Use Android Emulator

  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",
  3. Run pnpm dev at the project root folder.

3a. When it's time to add a new UI component

Run the ui-add script to add a new UI component using the interactive shadcn/ui CLI:

pnpm ui-add

When the component(s) has been installed, you should be good to go and start using it in your app.

3b. When it's time to add a new package

To add a new package, simply run pnpm turbo gen init in the monorepo root. This will prompt you for a package name as well as if you want to install any dependencies to the new package (of course you can also do this yourself later).

The generator sets up the package.json, tsconfig.json and a index.ts, as well as configures all the necessary configurations for tooling around your package such as formatting, linting and typechecking. When the package is created, you're ready to go build out the package.

FAQ

Does the starter include Solito?

No. Solito will not be included in this repo. It is a great tool if you want to share code between your Next.js and Expo app. However, the main purpose of this repo is not the integration between Next.js and Expo — it's the code splitting of your T3 App into a monorepo. The Expo app is just a bonus example of how you can utilize the monorepo with multiple apps but can just as well be any app such as Vite, Electron, etc.

Integrating Solito into this repo isn't hard, and there are a few official templates by the creators of Solito that you can use as a reference.

What auth solution should I use instead of Next-Auth.js for Expo?

I've left this kind of open for you to decide. Some options are Clerk, Supabase Auth, Firebase Auth or Auth0. Note that if you're dropping the Expo app for something more "browser-like", you can still use Next-Auth.js for those. See an example in a Plasmo Chrome Extension here.

The Clerk.dev team even made an official template repository integrating Clerk.dev with this repo.

During Launch Week 7, Supabase announced their fork of this repo integrating it with their newly announced auth improvements. You can check it out here.

Does this pattern leak backend code to my client applications?

No, it does not. The api package should only be a production dependency in the Next.js application where it's served. The Expo app, and all other apps you may add in the future, should only add the api package as a dev dependency. This lets you have full typesafety in your client applications, while keeping your backend code safe.

If you need to share runtime code between the client and server, such as input validation schemas, you can create a separate shared package for this and import it on both sides.

Deployment

Next.js

Prerequisites

Note Please note that the Next.js application with tRPC must be deployed in order for the Expo app to communicate with the server in a production environment.

Deploy to Vercel

Let's deploy the Next.js application to Vercel. If you've never deployed a Turborepo app there, don't worry, 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. Vercel's zero-config system should handle all configurations for you.

  2. Add your DATABASE_URL environment variable.

  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.

Auth Proxy

The auth proxy is a Nitro server that proxies OAuth requests in preview deployments. This is required for the Next.js app to be able to authenticate users in preview deployments. The auth proxy is not used for OAuth requests in production deployments. To get it running, it's easiest to use Vercel Edge functions. See the Nitro docs for how to deploy Nitro to Vercel.

Then, there are some environment variables you need to set in order to get OAuth working:

  • For the Next.js app, set AUTH_REDIRECT_PROXY_URL to the URL of the auth proxy.
  • For the auth proxy server, set AUTH_REDIRECT_PROXY_URL to the same as above, as well as AUTH_DISCORD_ID, AUTH_DISCORD_SECRET (or the equivalent for your OAuth provider(s)). Lastly, set AUTH_SECRET to the same value as in the Next.js app for preview environments.

Read more about the setup in the auth proxy README.

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 app stores, like Apple App Store and Google Play. You can read the full guide to distributing your app, including best practices, in the Expo docs.

  1. Make sure to modify the getBaseUrl function to point to your backend's production URL:

    const getBaseUrl = () => {
    /**
    * Gets the IP address of your host-machine. If it cannot automatically find it,
    * you'll have to manually set it. NOTE: Port 3000 should work for most but confirm
    * you don't have anything else running on it, or you'd have to change it.
    *
    * **NOTE**: This is only for development. In production, you'll want to set the
    * baseUrl to your production API URL.
    */
    const localhost = Constants.manifest?.debuggerHost?.split(":")[0];
    if (!localhost) {
    // return "https://your-production-url.com";
    throw new Error(
    "Failed to get localhost. Please point to your production server.",
    );
    }
    return `http://${localhost}:3000`;
    };

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

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

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

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

A blog post where I wrote how to migrate a T3 app into this.

create-t3-turbo's People

Contributors

ahkhanjani avatar azezsan avatar bycedric avatar carlosbm18 avatar cjkihl avatar dbianchii avatar felipeemos avatar filipweilid avatar gnllucena avatar hichemfantar avatar hoangtrung99 avatar imbaedin avatar johnslemmer avatar juliusmarminge avatar leifarriens avatar mattpocock avatar mendylanda avatar nkeil avatar noxify avatar odylomv avatar peterkibuchi avatar piotrekpkp avatar rajington avatar rdmchr avatar renovate[bot] avatar rndy28 avatar t3dotgg avatar tomheaton avatar uze avatar vaniapopovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

create-t3-turbo's Issues

Prisma broken for next when generating prisma client in non-node_modules dirs

My bad :(

Broke by my PR here:
#37

Error here, unable to find schema:
https://twitter.com/t3dotgg/status/1582936894991609857
image

Tried solution here:
prisma/prisma#10433 (comment)

Gets further, but new error:

@acme/nextjs:dev: prisma:query SELECT `main`.`Post`.`id`, `main`.`Post`.`title`, `main`.`Post`.`content` FROM `main`.`Post` WHERE 1=1 LIMIT ? OFFSET ?
@acme/nextjs:dev: prisma:query SELECT 1
@acme/nextjs:dev: prisma:query SELECT name FROM sqlite_schema
@acme/nextjs:dev:       WHERE type='table'
@acme/nextjs:dev:       ORDER BY name;
@acme/nextjs:dev:       
@acme/nextjs:dev: failed to fetch, PrismaClientKnownRequestError: 
@acme/nextjs:dev: Invalid `prisma.post.findMany()` invocation:
@acme/nextjs:dev: 
@acme/nextjs:dev: 
@acme/nextjs:dev: The table `main.Post` does not exist in the current database.
@acme/nextjs:dev:     at RequestHandler.handleRequestError (webpack-internal:///(api)/../../packages/db/.generated/client/runtime/index.js:31874:19)
@acme/nextjs:dev:     at RequestHandler.request (webpack-internal:///(api)/../../packages/db/.generated/client/runtime/index.js:31853:18)
@acme/nextjs:dev:     at async PrismaClient._request (webpack-internal:///(api)/../../packages/db/.generated/client/runtime/index.js:32853:24)
@acme/nextjs:dev:     at async eval (webpack-internal:///(api)/../../packages/api/src/router/post.ts:19:26)
@acme/nextjs:dev:     at async resolveMiddleware (file:///Users/theobrowne/Code/contrib/npm-turbo-t3/node_modules/@trpc/server/dist/router-28a2c129.mjs:190:30)
@acme/nextjs:dev:     at async callRecursive (file:///Users/theobrowne/Code/contrib/npm-turbo-t3/node_modules/@trpc/server/dist/router-28a2c129.mjs:226:32)
@acme/nextjs:dev:     at async resolve (file:///Users/theobrowne/Code/contrib/npm-turbo-t3/node_modules/@trpc/server/dist/router-28a2c129.mjs:254:24)
@acme/nextjs:dev:     at async file:///Users/theobrowne/Code/contrib/npm-turbo-t3/node_modules/@trpc/server/dist/resolveHTTPResponse-f2b378b6.mjs:374:32
@acme/nextjs:dev:     at async Promise.all (index 0)
@acme/nextjs:dev:     at async resolveHTTPResponse (file:///Users/theobrowne/Code/contrib/npm-turbo-t3/node_modules/@trpc/server/dist/resolveHTTPResponse-f2b378b6.mjs:371:28) {
@acme/nextjs:dev:   code: 'P2021',
@acme/nextjs:dev:   clientVersion: '4.5.0',
@acme/nextjs:dev:   meta: { table: 'main.Post' }
@acme/nextjs:dev: }

assumption is that it can't actually find the db in next, which is weird because it can totally find it in prisma studio? idk.

Expo tsconfig.json

I have a question.
What is tsconfig.base in the extends property in the tsconfig.json on the expo app ?

the expo app just doesn't work with trpc

I tried to run expo app but I got tired of it,

I tried it with

  • Yarn
  • NPM
  • PNPM

and in two different env

  • WSL2
  • Windows 11

after a while, this is the error I found and I think it's what stops it from bundling right
image

in the terminal shows no errors.

any ideas?

Adding a new package/app - node_modules folder not being created

Hi! I've created a repo using this template. (Repo for reference: https://github.com/mumlatz/mumlatz)

I've tried adding a new app (tried package as well). Steps:

  • Created a folder with a package.json file
  • adding some dependencies
  • run pnpm i

Expected: node_modules folder should be created
Actual: node_modules folder isn't being created

When I remove the line

node-linker=hoisted

from the .npmrc file, the node_modules folder does get created.

The strange thing is that even with this line there, when I delete the node_modules folder from an pre-existing app/package (IE - api, db, etc...) and re-run pnpm i, the node_modules folder will get created.

So basically what i'm asking is: What am I missing in my wiring to get the new package to work the same as the existing ones?

Things i've tried:
Adding the package to pnpm-workspace.yml and running pnpm i

Thanks!

PrismaClient is unable to be run in the browser

This issue occurs when attempting to import a type(enum in this case) from the prisma client in @acme/db into @acme/nextjs

Error
Error: PrismaClient is unable to be run in the browser. In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues

To reproduce, simply create an enum in Prisma and import said enum within NextJS.

schema.json

enum ExampleEnum {
    One
    Two
}

index.tsx

import { ExampleEnum } from '@acme/db`

Incorrect main in package.json of auth

Currently the auth package has this as it's main / types:

"main": "./src/index.ts", "types": "./src/index.ts",

The index.ts file however isn't in the src/ folder, it's in the root folder of the auth package.

This caused an issue for me when referencing this repository for my project however. Moving index.ts inside the src folder fixed this problem for me.

schema.prisma not found when using React Server Components

I started migration a side project of mine to react-t3-turbo

When I try to access a page that fetches data using prisma on a React Server Component, it gives an error of schema.prisma not found

Below is the code

image

and Below here is the error

image

If I copy the schema.prisma to ".nextjs/server/app/product" the error goes away

Add shared UI package

Hi, I am trying to add a new package for using shared components amongst all the packages available in the app, but whenever I try to import the ui package from NextJS or Expo I get ts(2307) error (Cannot find module).

Of course I am more than aware of me not knowing much about Turborepo as it's the first time I get to play with it 😥.

However, in short I would like to make a shared package to use the same React Native components in both the NextJS app (using React Native Web) and in React Native.

The steps I am currently following to do this are:

  • Clone create-t3-turbo
  • cd packages && mkdir ui
    • npm init -y
    • Add "react": "^18.2.0", "react-native": "^0.69.5" to package.json
    • Change project name to "@acme/ui" in package.json to comply with the rest of the packages and apps naming convention
    • Create a src/index.tsx file and export a React component (neither React or React-Native are working)
    • Create tsconfig.json file and add:
{
  "extends": "../../tsconfig.json",
  "include": ["src"]
}
  • cd ../../apps/nextjs
    • Add "@acme/ui": "*" to package.json
    • Add "@acme/ui" to next.config.mjs inside withTM's array attribute so it now looks like this:
export default withTM(["@acme/api", "@acme/db", "@acme/ui"])(
  defineNextConfig({
    reactStrictMode: true,
    swcMinify: true,
  })
);
  • cd ../.. && npm i (root folder)

Now every @acme/ui components should be visible from the NextJS app but when I import them as: import {Button} from "@acme/ui" I get that "Cannot find module" TypeScript error.

Thanks so much for your help.

Seems like EAS iOS building is having problem

I'm trying to get the Expo app built using EAS, building for iOS (simulator).

Here's what I've done:

  1. Follow what's in here until I get the step that builds for iOS Simulator
  2. Here's my build profile:
"iosPreview": {
  "ios": {
    "simulator": true
  }
},
  1. I build with eas build -p ios --profile iosPreview

The first time it fails, it's complaining about the entry point not being index.js. It is defined as src/_app in package.json. I provided the index.js as follow:

import { registerRootComponent } from "expo";
import App from "./src/App";

registerRootComponent(App);

I've changed src/_app.tsx to src/App.tsx, remove the registerRootComponent and go export default App.

It seems to build now. However I'm getting this Xcode Logs error in EAS Build after failing:

/Users/expo/.nvm/versions/node/v16.13.2/bin/node /Users/expo/workingdir/build/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output /Users/expo/workingdir/build/apps/expo/ios/build/Build/Products/Release-iphonesimulator/main.jsbundle --assets-dest /Users/expo/workingdir/build/apps/expo/ios/build/Build/Products/Release-iphonesimulator/iHaveTime.app
warning: the transform cache was reset.
                    Welcome to Metro!
              Fast - Scalable - Integrated
error Unable to resolve module @babel/runtime/helpers/interopRequireDefault from /Users/expo/workingdir/build/apps/expo/index.js: @babel/runtime/helpers/interopRequireDefault could not be found within the project or in these directories:

It seems that it needs @babel/runtime, but I'm not sure. I tried to npm i -D @babel/runtime and build again to see what happens. I'll come back with the result. Meanwhile it seems like the current Expo settings in this monorepo is not enough to build EAS iOS by following the Expo's guide. There's something missing and I'm trying to figure out which exactly is missing.

Update 1: Not working, same error. I'm trying again with dependencies instead of devDependencies. Don't know if a fresh Expo app will be able to build EAS without error (I'm trying one). If it's indeed the monorepo's error, metro.config.js might need some tweaks. https://docs.expo.dev/guides/monorepos/

Error when trying to use PNPM as package manager

Hey there, i'm having some trouble using pnpm instead of npm with this template. Maybe someone has some insight on what I'm missing.

Here is the repo with the changes I've made so far

Steps I made to change to pnpm

  • added pnpm-workspace.yaml with corresponding workspaces (apps and packages)
  • ran pnpm install

Everything seems to install correctly, however, when running, I get a few errors:

(Keep in mind I didn't change anything other than adding pnpm, and initially everything was running fine before pnpm)

1st error

Screenshot 2022-09-10 175610

However this error dissapeared after I updated trpc to 10.0.0-proxy-alpha.73

2nd error

@acme/nextjs:dev: error - Error: ENOENT: no such file or directory, open 'C:\Users\anon\create-t3-turbo-pnpm\apps\nextjs.next\server\pages\api\trpc\schema.prisma'
@acme/nextjs:dev: at Object.openSync (node:fs:585:3)
@acme/nextjs:dev: at Object.readFileSync (node:fs:453:35)
@acme/nextjs:dev: at new LibraryEngine (C:\Users\anon\create-t3-turbo-pnpm\node_modules@prisma\client\runtime\index.js:25992:41)
@acme/nextjs:dev: at PrismaClient.getEngine (C:\Users\anon\create-t3-turbo-pnpm\node_modules@prisma\client\runtime\index.js:30454:16)
@acme/nextjs:dev: at new PrismaClient (C:\Users\anon\create-t3-turbo-pnpm\node_modules@prisma\client\runtime\index.js:30426:29)
@acme/nextjs:dev: at eval (webpack-internal:///(api)/../../packages/db/index.ts:8:16)
@acme/nextjs:dev: at Module.(api)/../../packages/db/index.ts (C:\Users\anon\create-t3-turbo-pnpm\apps\nextjs.next\server\pages\api\trpc[trpc].js:175:1)
@acme/nextjs:dev: at webpack_require (C:\Users\anon\create-t3-turbo-pnpm\apps\nextjs.next\server\webpack-api-runtime.js:33:43)
@acme/nextjs:dev: at eval (webpack-internal:///(api)/../../packages/api/src/context.ts:6:66)
@acme/nextjs:dev: at Module.(api)/../../packages/api/src/context.ts (C:\Users\anon\create-t3-turbo-pnpm\apps\nextjs.next\server\pages\api\trpc[trpc].js:131:1) {
@acme/nextjs:dev: errno: -4058,
@acme/nextjs:dev: syscall: 'open',
@acme/nextjs:dev: code: 'ENOENT',
@acme/nextjs:dev: path: 'C:\Users\anon\create-t3-turbo-pnpm\apps\nextjs\.next\server\pages\api\trpc\schema.prisma',
@acme/nextjs:dev: clientVersion: '4.3.1'
@acme/nextjs:dev: }
@acme/nextjs:dev: TRPCClientError: invalid json response body at http://localhost:3000/api/trpc/post.all?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D reason: Unexpected token < in JSON at position 0
@acme/nextjs:dev: at Function.from (file:///C:/Users/anon/create-t3-turbo-pnpm/node_modules/.pnpm/@[email protected]_7jrqolvqjpfojvwms5forbwovm/node_modules/@trpc/client/dist/transformResult-106791d7.mjs:13:16)
@acme/nextjs:dev: at file:///C:/Users/anon/create-t3-turbo-pnpm/node_modules/.pnpm/@[email protected]_7jrqolvqjpfojvwms5forbwovm/node_modules/@trpc/client/dist/links/httpBatchLink.mjs:199:64
@acme/nextjs:dev: at runMicrotasks ()
@acme/nextjs:dev: at processTicksAndRejections (node:internal/process/task_queues:96:5) {
@acme/nextjs:dev: meta: undefined,
@acme/nextjs:dev: shape: undefined,
@acme/nextjs:dev: data: undefined,
@acme/nextjs:dev: [cause]: FetchError: invalid json response body at http://localhost:3000/api/trpc/post.all?batch=1&input=%7B%220%22%3A%7B%22json%22%3Anull%2C%22meta%22%3A%7B%22values%22%3A%5B%22undefined%22%5D%7D%7D%7D reason: Unexpected token < in JSON at position 0
@acme/nextjs:dev: at C:\Users\anon\create-t3-turbo-pnpm\node_modules.pnpm\[email protected]_zpnidt7m3osuk7shl3s4oenomq\node_modules\next\dist\compiled\node-fetch\index.js:1:51227
@acme/nextjs:dev: at runMicrotasks ()
@acme/nextjs:dev: at processTicksAndRejections (node:internal/process/task_queues:96:5) {
@acme/nextjs:dev: type: 'invalid-json'
@acme/nextjs:dev: }
@acme/nextjs:dev: }

At first sight it seems that the import path of prisma's schema is wrong but I can't figure out why this is happening only after installing pnpm. If anyone has some pointer to what could be happening I'd be most grateful.

Environment variable not found: DATABASE_URL

When I run npx prisma studio --schema ./packages/db/prisma/schema.prisma the prisma studio shows all data in my DB correctly, but when I run npx turbo run dev I get:



Invalid `prisma.post.count()` invocation:


error: Environment variable not found: DATABASE_URL.
  -->  schema.prisma:7
   | 
 6 |   provider = "postgresql"
 7 |   url      = env("DATABASE_URL")
   | 

Validation Error Count: 1

Do we need to add another .env in that folder or some other configuration?

[Improvement] Any plans to include next-auth ?

Hey there, I first would like to thank you for this amazing job. It's what I was looking for months on the Zart stack and it finally happened with you <3

I'm wondering if you are aware of this draft PR on next-auth, (original post here) that will probably allow us to use next-auth on expo apps and if yes, if your plan is to integrate it when it will be available to fully support the original T3 stack ?

Why pnpm over yarn workspaces

I understand the value of pnpm over yarn in most cases. However in an expo app to me it gets a little more complicated.

From the expo monorepo docs their example uses yarn workspaces. In the section about using other tools they list out a few rules. One of which is that all dependencies must live in a node_modules directory. pnpm by default doesn't do this.

The default settings of tools like pnpm do not follow these rules. You can change that by adding an .npmrc file with node-linker=hoisted (see docs). That config option will change the behavior to match these rules.

I know there's a node-linker=hoisted option which is what this boilerplate uses. However unless my understanding is incorrect this would mean there is no symlinking. So in our use case we want to have an apps/mobile folder with the expo app and a ui package that contains many components that will be consumed by the expo app. I think this would mean for the expo app to pull in changes made in the ui package we would need to run pnpm i every time we make a change in the ui folder. This seems like a seriously degraded developer experience.

The alternative would be using yarn workspaces without the nohoist flag as mentioned in the expo docs. I believe this would allow us to develop packages in the ui folder and automatically consume them in the app folder without having to run pnpm i

This is the first production grade mobile app monorepo project I've setup so I may be misunderstanding something of course.

`cache: true` doesn't do anything

In the turbo.json:

{
  "pipeline": {
    "db-generate": {
      "inputs": ["prisma/schema.prisma"],
      "cache": true
    },
  },
}

The db-generate has cache: true. This can lead to confusing results.

By default, Turborepo caches dist/**. By specifying cache: true here, you may end up with the task not being 'run' but no outputs being produced.

I'm still investigating the best approach here for the Turborepo docs, but for now my recommendation would be to specify cache: false and eat the 6 seconds it takes to run. At least it's O(1).

Next.js not working

Since last commit (64ec6ac) the Next.js app is not working anymore.
When I run npm run dev some errors appear on the console.

Server Error TypeError: Cannot read properties of null (reading 'useContext')

I tried with the previous commit and it was working.

Unable to resolve module ./index

Hey guys, love what you've done with this monorepo setup and the t3 stack :)

I've been running into this issue on my project:
Screenshot 2022-10-11 at 14 45 03

this happens when i try to run the bundled ios app using npx expo run:ios as well expo run:ios

this is happening on a clean clone of the repo as well as my personal project repo :(

would love if you could point me in the right direction.

Prisma Studio schema path

I tried getting Prisma Studio working, but it seemed like it couldn't find the DATABASE_URL. Since the schema.prisma file is not in the expected location, it seems to cause issues.

I was able to connect by adding the below to the package.json:

  "prisma": {
    "schema": "packages/db/prisma/schema.prisma"
  }

I'm also wondering if the db-generate and db-push inputs for turbo.json need to be updated?

Using NPM. `npm run dev` results in multiple `npm ERR! Workspaces not supported for global packages` errors

Here is the terminal log from a clean template creation using npm 8.6.0 and node V16.14.2 on Windows

> dev
> turbo run dev --parallel

• Packages in scope: @acme/api, @acme/db, @acme/expo, @acme/nextjs
• Running dev in 4 packages
@acme/db:dev: cache bypass, force executing 32a417cc7faf26d1
@acme/nextjs:dev: cache bypass, force executing 4577cc5915a64a16
@acme/expo:dev: cache bypass, force executing b4143d6f076bde8d
@acme/db:dev: npm ERR! Workspaces not supported for global packages
@acme/nextjs:dev: npm ERR! Workspaces not supported for global packages
@acme/db:dev:
@acme/db:dev: npm ERR! A complete log of this run can be found in:
@acme/db:dev: npm ERR!     C:\Users\reddacted\AppData\Local\npm-cache\_logs\2022-08-24T17_53_26_285Z-debug-0.log
@acme/nextjs:dev:
@acme/nextjs:dev: npm ERR! A complete log of this run can be found in:
@acme/nextjs:dev: npm ERR!     C:\Users\reddacted\AppData\Local\npm-cache\_logs\2022-08-24T17_53_26_284Z-debug-0.log
@acme/expo:dev: npm ERR! Workspaces not supported for global packages
@acme/expo:dev: 
@acme/expo:dev: npm ERR! A complete log of this run can be found in:
@acme/expo:dev: npm ERR!     C:\Users\reddacted\AppData\Local\npm-cache\_logs\2022-08-24T17_53_26_284Z-debug-0.log
@acme/expo:dev: 
@acme/expo:dev: > @acme/[email protected] dev
@acme/expo:dev: > expo start --ios
@acme/expo:dev:
@acme/db:dev:
@acme/db:dev: > @acme/[email protected] dev
@acme/db:dev: > prisma studio
@acme/db:dev:
@acme/nextjs:dev:
@acme/nextjs:dev: > @acme/[email protected] dev
@acme/nextjs:dev: > next dev
@acme/nextjs:dev:
@acme/nextjs:dev: ready - started server on 0.0.0.0:3000, url: http://localhost:3000
@acme/db:dev: Prisma schema loaded from prisma\schema.prisma
@acme/db:dev: Prisma Studio is up on http://localhost:5555
@acme/nextjs:dev: info  - SWC minify release candidate enabled. https://nextjs.link/swcmin
@acme/expo:dev: Starting project at D:\repos\senior\apps\expo
@acme/nextjs:dev: info  - automatically enabled Fast Refresh for 1 custom loader
@acme/expo:dev: Some dependencies are incompatible with the installed expo version:
@acme/expo:dev:   @shopify/[email protected] - expected version: 1.1.0
@acme/expo:dev:   [email protected] - expected version: 4.3.1
@acme/expo:dev: Your project may not work correctly until you install the correct versions of the packages.
@acme/expo:dev: Install individual packages by running npx expo install @shopify/[email protected] [email protected]
@acme/expo:dev: Starting Metro Bundler
@acme/nextjs:dev: event - compiled client and server successfully in 3s (223 modules)
@acme/nextjs:dev: wait  - compiling...
@acme/nextjs:dev: event - compiled client and server successfully in 94 ms (223 modules)
@acme/expo:dev: CommandError: Input is required, but 'npx expo' is in non-interactive mode.
@acme/expo:dev: Required input:
@acme/expo:dev: > Xcode needs to be installed (don't worry, you won't have to use it), would you like to continue to the App Store?
@acme/expo:dev: npm ERR! Lifecycle script `dev` failed with error:
@acme/expo:dev: npm ERR! Error: command failed
@acme/expo:dev: npm ERR!   in workspace: @acme/[email protected]
@acme/expo:dev: npm ERR!   at location: D:\repos\senior\apps\expo
@acme/expo:dev: ERROR: command finished with error: command (apps\expo) npm run dev exited (1)
@acme/nextjs:dev: wait  - compiling /_error (client and server)...
@acme/nextjs:dev: event - compiled client and server successfully in 66 ms (224 modules)
@acme/nextjs:dev: warn  - Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/basic-features/fast-refresh#how-it-works

Expo repo has an error with trpc AppRouter

Hi, first of all amazing template.

I was checking it file by file and seems like (after installing dependencies) there is an error at the trpc import in the expo project.
Exactly at expo/utils/trpc.ts when hooking AppRouter type with trpc.

export const trpc = createTRPCReact<AppRouter>();

Diagnostic error is the following

Type 'Router<RouterDef<{ prisma: any; }, DefaultErrorShape, never, { post: Router<RouterDef<{ prisma: any; }, DefaultErrorShape, never, { all: QueryProcedure<Overwrite<{ _config: { ctx: { prisma: any; }; meta: never; errorShape: DefaultErrorShape; transformer: CombinedDataTransformer; }; ... 6 more ...; _meta: never; }, {...' does not satisfy the constraint 'Router<any>'.
  The types returned by 'createCaller(...)' are incompatible between these types.
    Type '{ query: inferHandlerFn<Filter<{ post: Router<RouterDef<{ prisma: any; }, DefaultErrorShape, never, { all: QueryProcedure<Overwrite<{ _config: { ctx: { prisma: any; }; meta: never; errorShape: DefaultErrorShape; transformer: CombinedDataTransformer; }; ... 6 more ...; _meta: never; }, { ...; }>>; byId: QueryProcedur...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; } & DecoratedProcedureRecord<any>'.
      Type '{ query: inferHandlerFn<Filter<{ post: Router<RouterDef<{ prisma: any; }, DefaultErrorShape, never, { all: QueryProcedure<Overwrite<{ _config: { ctx: { prisma: any; }; meta: never; errorShape: DefaultErrorShape; transformer: CombinedDataTransformer; }; ... 6 more ...; _meta: never; }, { ...; }>>; byId: QueryProcedur...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
        Types of property 'query' are incompatible.
          Type 'inferHandlerFn<Filter<{ post: Router<RouterDef<{ prisma: any; }, DefaultErrorShape, never, { all: QueryProcedure<Overwrite<{ _config: { ctx: { prisma: any; }; meta: never; errorShape: DefaultErrorShape; transformer: CombinedDataTransformer; }; ... 6 more ...; _meta: never; }, { ...; }>>; byId: QueryProcedure<...>; }...' is not assignable to type 'inferHandlerFn<any>'.
            Types of parameters 'path' and 'path' are incompatible.
              Type 'TPath' is not assignable to type 'never'.
                Type 'string' is not assignable to type 'never'.ts(2344)

Steps to reproduce:

  1. Clone the repo
  2. Setup dependencies (follow the exact steps described in README.md)
  3. Open the trpc.ts file at expo/utils folder.

When running dev everything seems to be working fine so maybe I missed something (please let me know in that case).

bug: tailwind not hot reloading in dev

First of all, great work guys! this is amazing, really loving it so far.
I am not sure if this is a known issue or more on my side, but yeah as the title suggests, when i make changes to my tailwind config file i would like to have these changes hot reloaded, is this possible?
i wasn't sure if i needed to make changes to the package.json file or just include it as a transpile package.

thanks!

Type annotations file for custom env variables

Hey. I was wondering where is the best place is to place a typescript definition file which extends the process.env object to include the custom environmental variables used throughout the project. Maybe have one for each packages or app to only specific the env variables that are used in that submodule/app? dunno

This is how it usually looks like:

declare namespace NodeJS {
	interface ProcessEnv {
		DATABASE_URL: string;
		VERCEL_URL: string;
		NEXTAUTH_URL: string;
		NEXTAUTH_SECRET: string;
		DISCORD_CLIENT_ID: string;
		DISCORD_CLIENT_SECRET: string;
	}
}

What do you guys think? Where's the best place to place this file? Or should I have one per submodule? Thanks.

TailwindCSS with Radix UI + Headless UI

I'm trying to add some UI package in my fork of this repo.

I used this example from turborepo to create one with TailwindCSS and added Radix UI and Headless UI in it.
But I'm not getting the expected result, running the fork you will see that the behavior aspect it's not working properly. I tried a number of things to make it work, but with no success.
Someone with more experience or has gone through this can help me with this?

Enable migrations

I tried setting up migrations but with no luck, seems it might be a problem with pnpm.

I wanted to add a db-migrate-dev script with a corresponding one in the db package. Something like pnpm with-env prisma migrate dev. However when I ran it from the repo root, it never prompted me for a migration name, and the command never ended, it just hanged. Even with the --name <some_name> parameter it would not finish.

However I managed to make a migration if i cd into the db package and ran it from there. I also got it to work with npm in turborepo's own with-prisma example.

I tried some hoisting with no luck either.

I suspect it might be a problem with pnpm, prisma and that it is in a monorepo.

I saw some issues in the prisma repo about some issues with pnpm and node_modules, but was unable to get any wins from it.

Anyone have a solution for this?

Issues with EAS build - generating an apk file. Invariant Violation: "main" has not been registered.

I'm using EAS build to generate an apk file, but having some issues running the generated apk file on a device.

The build works fine, and I am able to generate the apk file and install it on an android device successfully. However, when I run it, it just crashes.

I managed to use Android studios logcat to see what the issue is, and I see the following error message

Invariant Violation: "main" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called.

My setup is pretty vanilla and similar to this one, so I'm not sure what I am missing.

Here is my package.json

{
 "name": "@weyonje/sp-app",
 "version": "0.0.1",
 "private": true,
 "main": "index.ts",
 "dependencies": {
   "@react-native-async-storage/async-storage": "~1.17.3",
   "@react-navigation/bottom-tabs": "6.4.0",
   "@react-navigation/native": "6.0.13",
   "@react-navigation/native-stack": "6.9.0",
   "@react-navigation/stack": "6.3.2",
   "@tanstack/react-query": "4.16.1",
   "@trpc/client": "10.0.0-rc.8",
   "@trpc/server": "10.0.0-rc.8",
   "@trpc/react-query": "10.0.0-rc.8",
   "@weyonje/api": "*",
   "@weyonje/helpers": "*",
   "expo": "46.0.16",
   "expo-device": "4.3.0",
   "expo-location": "~14.3.0",
   "expo-notifications": "0.16.1",
   "expo-splash-screen": "~0.16.2",
   "expo-status-bar": "~1.4.0",
   "nativewind": "2.0.11",
   "react": "18.2.0",
   "react-dom": "18.2.0",
   "react-native": "0.70.2",
   "react-native-heroicons": "3.2.0",
   "react-native-maps": "1.3.2",
   "react-native-maps-directions": "^1.9.0",
   "react-native-safe-area-context": "4.4.1",
   "react-native-screens": "3.18.0",
   "react-native-svg": "12.3.0",
   "react-native-vector-icons": "9.2.0",
   "react-native-web": "0.18.9",
   "yup": "0.32.11"
 },
 "devDependencies": {
   "@babel/core": "7.19.3",
   "@babel/preset-env": "7.19.4",
   "@babel/runtime": "7.19.4",
   "@types/react": "18.0.21",
   "@types/react-native": "0.70.4",
   "@types/react-native-vector-icons": "6.4.12",
   "postcss": "8.4.19",
   "tailwindcss": "3.2.4",
   "typescript": "4.9.3"
 },
 "scripts": {
   "start": "expo start",
   "clean": "rm -rf .expo .turbo node_modules",
   "android": "expo start --android",
   "ios": "expo start --ios",
   "web": "expo start --web"
 }
}

here is my index.ts

import { registerRootComponent } from 'expo'

import { App } from './src/_app'

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
registerRootComponent(App)

I have updated my metro.config.js following this issue, but it still won’t run.

Any one have any pointers?

Issue using Expo Vector Icons

Potentially an issue with getting to the icons package. I am able to import the icon family in the code and use it, and it auto-fills the names of the available icons, but I cannot get it to display anything. The following error is displayed in the log. I checked online for it, and it some people encountered an issue that this error was thrown if their file name had spaces in it, but I cannot see how that would apply here. I tried this with multiple font families and got the same error on all.

Error: Downloaded file for asset 'Ionicons.ttf' Located at http://192.168.1.220:19000/assets/../../node_modules/@expo/vector-icons/build/vendor/react-native-vector-icons/Fonts/Ionicons.ttf?platform=android&hash=b3263095df30cb7db78c613e73f9499a?platform=android&dev=true&hot=false failed MD5 integrity check

Works on a new expo app.

How do you use this?

Hello,

Sorry if this isn't the right place to ask this, if there's somewhere else, please let me know.

I like the t3-stack, and want to try having a monorepo for an expo app, website, and server.

How do you use this repo? There are a few things I'm confused about.

  1. According to the blog post (https://www.jumr.dev/blog/t3-turbo), you don't run it like create-t3-app.
  2. On tRPC's website, there is a t3-turbo example project (https://trpc.io/docs/example-apps#create-t3-turbo---t3-stack-with-expo-and-turborepo), and it says to use clone
  3. I thought that most people using this would be using it for their own projects rather than contributing back to this one. Wouldn't we want to fork instead in that case? However, there are 1.2k stars, and <100 forks, so it seems like that's not what we should do either.

What am I missing?

[Expo Web] webpack errors when expo start --web

Hi

I'm having an issue with expo running the project on web.

steps to reproduce:

  1. clone repo
  2. cd apps/expo and npx expo install @expo/webpack-config@^0.17.0 (this is what the expo cli tells us to install for web to work)
  3. change expo/package.json dev script to expo start --web
  4. in monorepo root, pnpm run dev

you should see an error like this:

Screenshot 2022-10-14 at 14 28 33

Prisma import in examples points to wrong location

Hello, awesome template!

When I used the template I simply did a npm i in the root and I noticed I got an error in apps/nextjs/src/pages/api/examples.ts on line 3 . I had to change the import to import { prisma } from "../../../../../packages/db" before the prisma client could be found.

examples.ts

Please let me know if I did something wrong here.

bug: failing to integrate jest testing

I'm trying to build a monorepo that contains our backend, expo mobile app and nextjs web app. We'd also like to have a packages/ui folder that contains React Native components we create build with Nativewind and use them in the mobile app and nextjs app.

I have it all configured to work properly at runtime but our jest testing seems to be an issue.

Jest tests inside our ui package were failing. Running npx expo install jest seemed to fix that.
Jest tests inside our apps/mobile app were failing and npx expo install jest got us a bit further.

However the issue I have now is the only way I can get jest tests to pass in apps/mobile is if I do jest.mock('ui') in the jest setup for apps/mobile.

The error Jest throws is:

 FAIL  src/app.test.tsx
  ● Test suite failed to run

    Invariant Violation: __fbBatchedBridgeConfig is not set, cannot invoke native modules

      at invariant (../../node_modules/invariant/invariant.js:40:15)
      at Object.<anonymous> (../../packages/ui/node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:181:3)
      at Object.<anonymous> (../../packages/ui/node_modules/react-native/Libraries/TurboModule/TurboModuleRegistry.js:11:23)

I would think that's because the ui package is including native modules but right now its just an incredible simple button we're trying to import.

import React from 'react'
import { styled } from 'nativewind'
import { Text, TextProps, Pressable, PressableProps, View } from 'react-native'

export type ButtonProps = PressableProps & {
  textStyle?: TextProps['style']
  children?: JSX.Element | JSX.Element[] | string
}

export const Button = styled(
  ({ textStyle, children, ...props }: ButtonProps) => {
    return (
      <Pressable {...props} accessibilityRole="button">
        <View style={textStyle}>
          <Text>{children}</Text>
        </View>
      </Pressable>
    )
  },
  'text-indigo-50'
)

The ui package.json is also simple and just looks like this

{
  "name": "ui",
  "version": "0.0.0",
  "main": "./index.ts",
  "license": "MIT",
  "scripts": {
    "lint": "eslint *.ts*",
    "test": "jest .",
    "tsc": "tsc --noEmit"
  },
  "devDependencies": {
    "@testing-library/jest-native": "^5.0.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/react-native": "^11.2.0",
    "@types/jest": "^29.1.2",
    "@types/react": "^18.0.21",
    "@types/react-dom": "^18.0.5",
    "@types/react-native": "~0.69.6",
    "eslint": "^7.32.0",
    "eslint-config-heir-base": "workspace:*",
    "jest": "^26.6.3",
    "jest-expo": "^46.0.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "typescript": "^4.5.2"
  },
  "dependencies": {
    "nativewind": "^2.0.5",
    "react-native": "0.69.6"
  }
}

Any idea what could be incorrect regarding our configuration?

feat: better way to validate / import env vars

Hello! I am moving a create-t3-app project to a turborepo based on this template, and I notice that the env checker remains in the next folder, contrary to what I would have thought since now it wouldn't be fully checking the env variables for other apps or packages. It would be great to add a new package that checks all as a dependency in the TurboRepo workflows, similar to the env folder in @acme/next.

[Improvement] Any plan to use Solito?

I just started looking into this project because I wanted to see if I could possibly move my Solito project to this starter but it seems like there's no shared navigation and no sharing of components / screens in this repo unless I'm missing something.

Is Solito something you're planning to add later on?

Saw someone else had something started with Solito but probably won't be as nicely maintained as what you're building and I struggled deploying it.
https://github.com/chamatt/create-kaol-app

NEXTAUTH_SECRET doesn't work in production

I tried getting the stack working all the way through but kept getting an error where NextAuth would say I didn't have a secret in production even though I had NEXTAUTH_SECRET set in prod for my app.

It seems like I have it working by adding secret: process.env.NEXTAUTH_SECRET, in auth-options.ts.

It's a small change but I can't seem to create a branch or PR.

pnpm dev error

Hi there, iam experiencing an issue after running pnpm dev

reproduce:

git clone https://github.com/t3-oss/create-t3-turbo
cd create-t3-turbo && pnpm i
// change db provider in prisma.schema
echo DATABASE_URL=file:./db.sqlite >> packages/db/.env
pnpm db-push
pnpm dev
// open localhost:3000

logs

@acme/nextjs:dev: error - Error: ENOENT: no such file or directory, open '/home/rndy/Documents/programming-related/Projects/portfolios/goodiebook-turborepo/apps/nextjs/.next/server/pages/api/trpc/schema.prisma'
@acme/nextjs:dev:     at Object.openSync (node:fs:594:3)
@acme/nextjs:dev:     at Object.readFileSync (node:fs:462:35)
@acme/nextjs:dev:     at new LibraryEngine (webpack-internal:///(api)/../../packages/db/node_modules/@prisma/client/runtime/index.js:26943:41)
@acme/nextjs:dev:     at PrismaClient.getEngine (webpack-internal:///(api)/../../packages/db/node_modules/@prisma/client/runtime/index.js:31383:16)
@acme/nextjs:dev:     at new PrismaClient (webpack-internal:///(api)/../../packages/db/node_modules/@prisma/client/runtime/index.js:31355:29)
@acme/nextjs:dev:     at eval (webpack-internal:///(api)/../../packages/db/index.ts:8:16)
@acme/nextjs:dev:     at Object.(api)/../../packages/db/index.ts (/home/rndy/Documents/programming-related/Projects/portfolios/goodiebook-turborepo/apps/nextjs/.next/server/pages/api/trpc/[trpc].js:374:1)
@acme/nextjs:dev:     at __webpack_require__ (/home/rndy/Documents/programming-related/Projects/portfolios/goodiebook-turborepo/apps/nextjs/.next/server/webpack-api-runtime.js:33:42)
@acme/nextjs:dev:     at eval (webpack-internal:///(api)/../../packages/api/src/context.ts:6:66)
@acme/nextjs:dev:     at Object.(api)/../../packages/api/src/context.ts (/home/rndy/Documents/programming-related/Projects/portfolios/goodiebook-turborepo/apps/nextjs/.next/server/pages/api/trpc/[trpc].js:330:1) {
@acme/nextjs:dev:   errno: -2,
@acme/nextjs:dev:   syscall: 'open',
@acme/nextjs:dev:   code: 'ENOENT',
@acme/nextjs:dev:   path: '/home/rndy/Documents/programming-related/Projects/portfolios/goodiebook-turborepo/apps/nextjs/.next/server/pages/api/trpc/schema.prisma',
@acme/nextjs:dev:   clientVersion: '4.4.0'
@acme/nextjs:dev: }

issue still persisted after adding shamefully-hoist="true" to .npmrc

Should I use this in the "real world"/production yet?

Sorry for the big noob question here. I know turbopack is the new kid on the block, but if you're deploying on vercel anyways they ought to support that right? In what scenarios should I ignore turbo?

This question might be less about this template more so "how do I pick a technology thats good and will grow with me" sort of thing. Sorry if that's the case.

Thanks in advance.

Edit: Assuming I set up my own auth

Issue with next-auth while signIn (Generic Error page)

Heello, first of all, thanks for all work in this repo 😄

I started a blank project and encountered this issue while trying to auth

error.mov

I don't know why exactly that happened, and no errors were being logged (even with next-auth debug mode on).

After exploring it a bit, I managed to solve it by changing the [...nextauth].ts API route and just spread the authOption variable

import NextAuth from "next-auth";
import { authOptions } from "@acme/auth";

export default NextAuth({
  ...authOptions,
});
after.mov

I don't know if someone else faced the same issue, if that is the case I can create a PR with the change 😅


  • Node: v18.12.1
  • pnpm: 7.18.0
  • Brave: 1.45.133

React Native Skia not working on installing

Summary
App crushes after doing npx expo install @shopify/react-native-skia

The error is Unable to resolve module scheduler/tracing, I read that its a misconfiguration between React and React Native.

My project is a monorepo and has React 18.0.0 and React Native 0.69.5 as dependencies. I tried nohost on react and react native but didn't work.

expo-app:dev: [18:25:03] node_modules
expo-app:dev: [18:25:03] ../../node_modules
expo-app:dev: [18:25:03] 18 | var _assign = require('object-assign');
expo-app:dev: [18:25:03] 19 | var Scheduler = require('scheduler');
expo-app:dev: [18:25:03] > 20 | var tracing = require('scheduler/tracing');
expo-app:dev: [18:25:03] | ^
expo-app:dev: [18:25:03] 21 |
expo-app:dev: [18:25:03] 22 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
expo-app:dev: [18:25:03] 23 |
What platform(s) does this occur on?
Not Applicable

Environment
./apps/expo/package.json

{
  "name": "expo-app",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "dev": "yarn env:development && npx expo r -c ",
    "prod": "yarn env:production && expo start --no-dev",
    "env:production": "cp .env.production .env",
    "env:development": "cp .env.development .env",
    "lint": "eslint . --ext .ts,.tsx,.js,.jsx,.json"
  },
  "dependencies": {
    "@andescalada/api": "*",
    "@andescalada/climbs-drawer": "*",
    "@andescalada/ui": "*",
    "@andescalada/utils": "*",
    "@datadog/mobile-react-native": "^1.0.0-rc7",
    "@datadog/mobile-react-navigation": "^1.0.0-rc8",
    "@expo/react-native-action-sheet": "^3.13.0",
    "@hookform/resolvers": "^2.9.8",
    "@openspacelabs/react-native-zoomable-view": "^2.0.4",
    "@prisma/client": "^3.8.1",
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-picker/picker": "2.4.2",
    "@react-navigation/native": "^6.0.12",
    "@react-navigation/stack": "^6.2.3",
    "@reduxjs/toolkit": "^1.8.5",
    "@shopify/react-native-skia": "0.1.141",
    "@shopify/restyle": "^2.1.0",
    "buffer": "^6.0.3",
    "dotenv": "^16.0.2",
    "expo": "~46.0.9",
    "expo-auth-session": "~3.7.1",
    "expo-constants": "~13.2.4",
    "expo-crypto": "~11.0.0",
    "expo-font": "~10.2.0",
    "expo-image-picker": "~13.3.1",
    "expo-random": "~12.3.0",
    "expo-splash-screen": "~0.16.2",
    "expo-status-bar": "~1.4.0",
    "expo-tracking-transparency": "~2.3.1",
    "jwt-decode": "^3.1.2",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "react-hook-form": "^7.35.0",
    "react-native": "0.69.5",
    "react-native-dotenv": "^3.3.1",
    "react-native-gesture-handler": "~2.5.0",
    "react-native-reanimated": "~2.9.1",
    "react-native-safe-area-context": "4.3.1",
    "react-native-screens": "~3.15.0",
    "react-native-svg": "12.3.0",
    "react-native-web": "~0.18.7",
    "react-redux": "^8.0.2"
  },
  "devDependencies": {
    "@babel/core": "^7.4.0-0",
    "@types/jwt-decode": "^3.1.0",
    "@types/react-native": "~0.69.5",
    "expo-cli": "^6.0.5",
    "prisma": "^3.8.1",
    "typescript": "^4.6.3"
  },
  "peerDependencies": {
    "react": "*",
    "zod": "*"
  },
  "private": true
}

./package.json

{
  "name": "andescalada",
  "private": true,
  "version": "0.0.1",
  "author": "elevyg",
  "license": "MIT",
  "scripts": {
    "db-up": "pscale connect andescalada develop --port 3309",
    "dev:nextjs": "turbo run dev --filter=@andescalada/nextjs",
    "dev:expo": "turbo run dev --filter=expo-app",
    "build": "turbo run build",
    "lint": "turbo run lint",
    "format": "prettier --write \"**/*.{ts,tsx,md}\"",
    "dev": "turbo run dev",
    "clean": "find . -name node_modules -o -name .next -o -name .expo -type d -prune | xargs rm -rf",
    "postinstall": "prisma generate",
    "lint-and-fix": "eslint . --ext .ts,.tsx,.js,.jsx,.json --fix",
    "prettier-format": "prettier --config .prettierrc '**/*.{json,js,jsx,ts,tsx,css,scss,md}' --write"
  },
  "workspaces": {
    "packages": [
      "packages/*",
      "apps/*"
    ]
  },
  "dependencies": {
    "@tanstack/react-query": "^4.3.9",
    "@trpc/client": "^10.0.0-proxy-beta.0",
    "@trpc/next": "^10.0.0-proxy-beta.0",
    "@trpc/react": "^10.0.0-proxy-beta.0",
    "@trpc/server": "^10.0.0-proxy-beta.0",
    "react": "18.0.0",
    "react-dom": "18.0.0",
    "zod": "^3.19.1"
  },
  "devDependencies": {
    "@types/react": "^18.0.0",
    "@types/react-dom": "^18.0.0",
    "@typescript-eslint/eslint-plugin": "^5.0.0",
    "@typescript-eslint/parser": "^5.0.0",
    "eslint": "^7.32.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-config-react": "^1.1.7",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-prettier": "^3.4.0",
    "eslint-plugin-react": "^7.24.0",
    "eslint-plugin-react-hooks": "^4 || ^3 || ^2.3.0 || ^1.7.0",
    "eslint-plugin-simple-import-sort": "^8.0.0",
    "prettier": "^2.4.0",
    "prisma": "^3.8.1",
    "turbo": "^1.3.1",
    "typescript": "^4.6.3"
  },
  "resolutions": {
    "@types/react": "17.0.43"
  }
}

Minimal reproducible example
My repo is private but it is reproducible with the create-t3-turbo template Clone this repo https://github.com/elevyg/create-t3-turbo

Steps to reproduce

yarn install
cd apps/expo
expo r -c

Screen Shot of the error
IMG_37735F453266-1

Old client support

Hi,

I'm curious about the combination of tRPC and native apps. What is the recommended strategy for making sure previous client releases don't break when making changes to tRPC procedures?

It would be nice to be able to catch in dev or CI that a tRPC change "breaks" the type contract of an earlier release, maybe through some kind of contract snapshot generation that could be stored in the repo.

Apologies in advance if this already exists or somehow isn't necessary.

Inconsistency issue in quick start

The quickstart guide explains how to configure the local db .env file with a sqlite filesystem url, however the provider configuration in the prisma schema is set to postgresql.

provider = "postgresql"

I think this leads to an error when running the quickstart instructions as-is:

$ npm run db-push
...
Error: Schema validation error - Error (query-engine-node-api library)
Error code: P1012
error: Error validating datasource `db`: the URL must start with the protocol `postgresql://` or `postgres://`.
  -->  schema.prisma:10
   | 
 9 |     provider = "postgresql"
10 |     url      = env("DATABASE_URL")
   | 

Do you think it would be better to set provider = "sqlite" in the template's schema file by default?

[README] "just run pnpm dev and scan the QR-code" - fails because package.json dev specifies iOS

Love this template!!

One small issue with the getting started guide - README notes:

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

apps/expo/package.json contains:

"scripts": {
    "start": "expo start",
    "dev": "expo start --ios",
    "clean": "rm -rf .expo .turbo node_modules",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "lint": "eslint . --ext ts,tsx"
  },

Running pnpm dev tries to launch iOS, which on non-iOS platforms prompts for Xcode install

Possible solutions:

  • Change readme
  • Change apps/expo/package.json to not default to --ios

Thoughts on approach if I were to make the edit?

TRPCClientError when running default app on iOS

I tried to clone and run this repo by following the Readme:

  • added Sqlite as the prisma provider
  • echo DATABASE_URL=file:./db.sqlite >> packages/db/.env
  • ran npm run db-push
  • changed dev script in expo app to "dev": "expo start --ios"
  • ran npm run dev at the root of the project

Next app and Prisma studio run both well without errors/warnings but on the iOS simulator (iPhone 14 Pro Max) a warning appear on expo app at launch and when I try to add a post (posts are not added to the db so mutation fails):
SCR-20221003-vfp

This is logged in the console which run the process:
WARN [TRPCClientError: JSON Parse error: Unrecognized token '<']

Any ideas on what's going wrong here ?

MacOS 12.6
M1 Pro chip
Node v16.17.0

iPhone 14 Pro Max
iOS 16

Android Studio/Prisma Studio Clash

Android Studio by default runs on the port 5555, which is also the default port for Prisma Studio. As Android studio will likely be used quite frequently with a package like this, it might be worth defining a different port for Prisma Studio to launch in by default.

This can easily be changed by adding --port 5000 or whatever port you want it to run on in the dev script on packages/db/package.json

If you think this is worthwhile I can make a quick pr.

Alternative to using expo on the mobile side

Is it possible to have a standard react native app without the expo component? With create-t3-app we have the alternative pathway of deploying not just to vercel but to any number of hosts. I would be nice if create-t3-turbo was able to run a pure react native app to optionally remove the dependancy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.