Here is the folder structure of this app.
yt-clone/
|- migrations/
|- public/
|- src/
|-- app/
|--- (auth)/
|--- (home)/
|--- (studio)/
|--- api/
|--- apple-icon.png
|--- error.tsx
|--- favicon.ico
|--- globals.css
|--- icon0.svg
|--- icon1.png
|--- layout.tsx
|--- manifest.json
|--- not-found.tsx
|-- components/
|--- providers/
|--- ui/
|--- filter-carousel.tsx
|--- infinite-scroll.tsx
|--- responsive-modal.tsx
|--- user-avatar.tsx
|-- config/
|--- http-status-codes.ts
|--- index.ts
|-- constants/
|--- index.ts
|-- db/
|--- index.ts
|--- schema.ts
|-- env/
|--- client.ts
|--- server.ts
|-- hooks/
|--- use-confirm.tsx
|--- use-intersection-observer.ts
|--- use-mobile.tsx
|-- lib/
|--- encryption.ts
|--- mux.ts
|--- qstash.ts
|--- ratelimit.ts
|--- redis.ts
|--- uploadthing.ts
|--- utils.ts
|-- modules/
|--- auth/
|--- categories/
|--- comment-reactions/
|--- comments/
|--- home/
|--- playlists/
|--- search/
|--- studio/
|--- subscriptions/
|--- suggestions/
|--- users/
|--- video-reactions/
|--- video-views/
|--- videos/
|-- scripts/
|--- seed-categories.ts
|-- trpc/
|--- routers/
|--- client.tsx
|--- init.ts
|--- query-client.ts
|--- server.tsx
|-- proxy.ts
|- .env.example
|- .env/.env.local
|- .gitignore
|- .prettierrc.mjs
|- bun.lock
|- components.json
|- drizzle.config.ts
|- environment.d.ts
|- eslint.config.mjs
|- next.config.ts
|- package.json
|- postcss.config.mjs
|- tailwind.config.ts
|- tsconfig.json
|- vercel.ts- Make sure Git and NodeJS is installed.
- Clone this repository to your local computer.
- Create
.env.localfile in root directory. - Contents of
.env.local:
# disable telemetry
DO_NOT_TRACK="1"
CLERK_TELEMETRY_DISABLED="1"
CLERK_TELEMETRY_DEBUG="1"
NEXT_TELEMETRY_DISABLED="1"
# app base url
NEXT_PUBLIC_APP_BASE_URL="http://localhost:3000"
# clerk api keys
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="pk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
CLERK_SECRET_KEY="sk_test_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# clerk webhook
CLERK_WEBHOOK_SECRET="whsec_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# clerk redirect urls
NEXT_PUBLIC_CLERK_SIGN_IN_URL="/sign-in"
NEXT_PUBLIC_CLERK_SIGN_UP_URL="/sign-up"
NEXT_PUBLIC_CLERK_SIGN_IN_FALLBACK_REDIRECT_URL="/"
NEXT_PUBLIC_CLERK_SIGN_UP_FALLBACK_REDIRECT_URL="/"
# neon db uri
DATABASE_URL="postgresql://<username>:<password>@<hostname>/NewTube?sslmode=require"
# upstash redis url and token
UPSTASH_REDIS_REST_URL="https://<db-slug>.upstash.io"
UPSTASH_REDIS_REST_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# qstash token, url and keys
QSTASH_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
UPSTASH_WORKFLOW_URL="https://<slug>.ngrok-free.app"
QSTASH_CURRENT_SIGNING_KEY="sig_xxxxxxxxxxxxxxxxxxxxxxxx"
QSTASH_NEXT_SIGNING_KEY="sig_xxxxxxxxxxxxxxxxxxxxxxxxxxx"
# mux image and stream base url
NEXT_PUBLIC_MUX_IMAGE_BASE_URL="https://image.mux.com"
NEXT_PUBLIC_MUX_STREAM_BASE_URL="https://stream.mux.com"
# mux token and webhook secret
MUX_TOKEN_ID="xxxxxxxxx-xxx-xxxx-xxxx-xxxxxxxxxxxxxx"
MUX_TOKEN_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
MUX_WEBHOOK_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# uploadthing app id and token
UPLOADTHING_APP_ID="xxxxxxxxx"
UPLOADTHING_TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
# openai api base url
OPENAI_API_BASE_URL="https://api.openai.com/v1"
# open ai api key cookie name and verification secret (generated by `openssl rand -hex 32`)
OPENAI_API_KEY_COOKIE_NAME="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
VERIFICATION_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
DO_NOT_TRACK="1"
CLERK_TELEMETRY_DISABLED="1"
CLERK_TELEMETRY_DEBUG="1"
NEXT_TELEMETRY_DISABLED="1"- These disable analytics/telemetry from Clerk and Next.js. Keep them as provided.
NEXT_PUBLIC_APP_BASE_URL="http://localhost:3000"- Keep as
http://localhost:3000during development. - Change to your deployed URL (e.g.,
https://yourdomain.com) in production.
- Go to Clerk Dashboard.
- Create a new application.
- Navigate to API Keys:
- Copy Publishable Key →
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY - Copy Secret Key →
CLERK_SECRET_KEY
- Copy Publishable Key →
- Set up a Webhook (under "Webhooks") pointing to:
https://<your-domain>/api/users/webhook(this will be your server endpoint, can be tunneled via ngrok). Copy the generated secret →CLERK_WEBHOOK_SECRET - Redirect URLs: Keep as provided unless you modify authentication routes.
- Sign up at Neon.
- Create a new PostgreSQL project.
- Go to Connection Details and copy the Connection String.
- Replace
<username>,<password>, and<hostname>with your Neon credentials. - Append
?sslmode=requireat the end (needed for secure connections).
- Sign up at Upstash.
- Create a Redis database.
- In the database dashboard:
- Copy the REST URL →
UPSTASH_REDIS_REST_URL - Copy the REST Token →
UPSTASH_REDIS_REST_TOKEN
- Copy the REST URL →
- In your Upstash Dashboard, create a QStash project.
- Copy the QStash Token →
QSTASH_TOKEN. - Configure your Workflow URL (this will be your server endpoint, can be tunneled via ngrok).
- Obtain the Signing Keys from the QStash dashboard:
- Current Signing Key →
QSTASH_CURRENT_SIGNING_KEY - Next Signing Key →
QSTASH_NEXT_SIGNING_KEY
- Current Signing Key →
- Sign up at Mux and create a new project.
- In your Dashboard → Settings → API Access Tokens:
- Create a new token with Videos (Read & Write) permissions.
- Copy Token ID →
MUX_TOKEN_ID - Copy Token Secret →
MUX_TOKEN_SECRET
- Set up a Webhook in Mux (point to
https://<your-domain>/api/videos/webhook(this will be your server endpoint, can be tunneled via ngrok).) and copy the Webhook Signing Secret →MUX_WEBHOOK_SECRET
- Sign up at UploadThing.
- Create a new app.
- Copy the App ID →
UPLOADTHING_APP_ID - Copy the API Token →
UPLOADTHING_TOKEN
-
Store it in your cookies under the name specified by
OPENAI_API_KEY_COOKIE_NAME. -
Generate both verification secret and cookie name (for cryptographic signing):
openssl rand -hex 32
Copy the output →
VERIFICATION_SECRETandOPENAI_API_KEY_COOKIE_NAMEseparately
-
Install Project Dependencies using
npm install --legacy-peer-depsoryarn install --legacy-peer-depsorbun install --legacy-peer-deps. -
Now app is fully configured 👍 and you can start using this app using either one of
npm run devoryarn devorbun dev.
NOTE: Please make sure to keep your API keys and configuration values secure and do not expose them publicly.
You might encounter some bugs while using this app. You are more than welcome to contribute. Just submit changes via pull request and I will review them before merging. Make sure you follow community guidelines.
Useful resources and dependencies that are used in NewTube.
- Thanks to CodeWithAntonio: https://codewithantonio.com/
- @babel/eslint-parser: ^7.28.6
- @clerk/nextjs: ^6.37.4
- @eslint/eslintrc: ^3
- @hookform/resolvers: ^5.1.1
- @ianvs/prettier-plugin-sort-imports: ^4.7.1
- @mux/mux-node: ^12.8.0
- @mux/mux-uploader-react: ^1.4.1
- @mux/mux-video-react: ^0.29.0
- @neondatabase/serverless: ^1.0.2
- @radix-ui/react-avatar: ^1.1.11
- @radix-ui/react-dialog: ^1.1.14
- @radix-ui/react-dropdown-menu: ^2.1.15
- @radix-ui/react-label: ^2.1.8
- @radix-ui/react-select: ^2.2.5
- @radix-ui/react-separator: ^1.1.8
- @radix-ui/react-slot: ^1.2.4
- @radix-ui/react-tooltip: ^1.2.7
- @radix-ui/react-visually-hidden: ^1.2.4
- @t3-oss/env-nextjs: ^0.13.8
- @tanstack/react-query: ^5.80.7
- @trpc/client: ^11.10.0
- @trpc/react-query: ^11.7.2
- @trpc/server: ^11.6.0
- @types/node: ^25
- @types/react: 19.2.14
- @types/react-dom: 19.2.3
- @uploadthing/react: ^7.3.2
- @upstash/ratelimit: ^2.0.5
- @upstash/redis: ^1.36.2
- @upstash/workflow: ^0.2.14
- @vercel/config: ^0.0.33
- class-variance-authority: ^0.7.1
- client-only: ^0.0.1
- clsx: ^2.1.1
- concurrently: ^9.1.2
- date-fns: ^4.1.0
- dotenv: ^17.2.3
- drizzle-kit: ^0.31.5
- drizzle-orm: ^0.45.1
- drizzle-zod: ^0.8.2
- embla-carousel-react: ^8.6.0
- eslint: ^10
- eslint-config-next: 16.1.6
- eslint-config-prettier: ^10.0.1
- eslint-plugin-prettier: ^5.5.5
- eslint-plugin-tailwindcss: ^3.18.0
- jiti: ^2.6.1
- lucide-react: ^0.564.0
- next: 16.1.6
- openai: ^5.22.1
- player.style: ^0.3.0
- postcss: ^8
- prettier: ^3.8.1
- prettier-plugin-tailwindcss: ^0.7.2
- react: 19.2.4
- react-dom: 19.2.4
- react-error-boundary: ^6.0.0
- react-hook-form: ^7.71.2
- react-hot-toast: ^2.5.2
- server-only: ^0.0.1
- superjson: ^2.2.6
- tailwind-merge: ^3.4.1
- tailwindcss: ^3.4.1
- tailwindcss-animate: ^1.0.7
- typescript: ^5
- uploadthing: ^7.7.3
- vaul: ^1.1.2
- zod: ^4.1.13
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out Next.js deployment documentation for more details.
You can also give this repository a star to show more people and they can use this repository.



