πŸ”΄ Let’s build a Generative AI App with NEXT.JS 14! (OpenAI, Streaming, AI Agent, TS, GPTScript)

Sonny Sangha β€’ June 21, 2024
Video Thumbnail
Sonny Sangha Logo

Sonny Sangha

@sonnysangha

About

I'm Sonny. πŸ’― You might also know me as PAPA React! I've been coding for over 10 years now. As a Full Stack developer I've worked both with startups and large corporations to help build & scale their companies. Along the journey I realised my passion existed in helping others excel and pursue their dreams as upcoming developers and if that’s not enough I have cloned most of the applications you have used in your life! 🌟 🚨 Join the world’s BEST developer community β€œZero to Full Stack Hero” NOW: https://www.papareact.com/course

Video Description

❗️ Get started with GPTScript Today: https://links.papareact.com/gptscript ❗️❗️ Get the 'story-book.gpt' script for FREE here: https://www.papareact.com/gptscript-opt-in-form 🚨 Join the world’s BEST developer community & course Zero to Full Stack Hero: https://www.papareact.com/course πŸ› οΈ Looking for the Code for this build? (Plus over 50+ others!) https://links.papareact.com/github Join me as I show you how to build a StoryTeller AI App from scratch with the latest Next.js 14. You'll learn the following in this build: πŸ‘‰ How to implement GPTScript to create an AI Agent assistant capable of chaining AI tasks together - we'll build a Storybook with beautiful text & images, completely built from the AI agent's initial single prompt! πŸ‘‰ Ability to See a Real-Time Process of the Storybook Creation Process! (See the AI Agent in action!) πŸ‘‰ Ability to Store All Previously Created Stories by writing to the server... in fact the AI Agent does this for us! πŸ‘‰ How to build API routes using the app router Route Handler syntax πŸ‘‰ How to implement streaming to stream in the AI Agent's processes in real-time from our API endpoint! πŸ‘‰ How to utilise the power of caching in Next.js to create an optimal & efficient user experience! πŸ‘‰ How to use Next.js Server Components & Client Components and when/where to use them! πŸ‘‰ How to Integrate OpenAI into the Build πŸ‘‰ Create a Beautiful UI & UX for our Frontend using the highly Popular Shadcn & Tailwind CSS πŸ‘‰ How to use TypeScript to reduce the overall number of Bugs and Errors πŸ‘‰ How to deploy the final build on Vercel 🎡 WANT TO LISTEN TO THE EXCLUSIVE PAPAFAM PLAYLIST? Sign up for the PAPAFAM Newsletter here πŸ‘‰ https://links.papareact.com/newsletter πŸ• TIMESTAMPS: 00:00 Introduction 01:10 Build Demo 09:08 Build Tech 12:52 Explaining GPTScript 19:00 Initialising the Build 26:00 Building the Header Component 33:36 Implementing Shadcn/ui 35:38 Building the Nav Icons for the Header Component 38:24 Building the Home Page 44:56 Building the Story Writer Component 58:15 Building the AI Terminal Viewer 1:10:21 Creating an API Endpoint (1/2) 1:11:54 Setting Up GPTScript 1:16:27 Creating an API Endpoint (2/2) 1:21:04 Implementing GPTScript 1:28:38 Implementing the Streaming Functionality 1:50:44 Explaining How the Streaming Functionality Works 1:57:29 Fetching All the Stories 2:13:52 Building the Stories Page 2:29:01 Building the Story Book Carousel View 2:39:03 Implementing Toast Notifications 2:43:11 Final Build Demo 2:50:17 Deploying to Vercel 2:54:22 Build Summary Let’s get it PAPAFAM πŸ”₯. DISCLAIMER: This Video is made for informational and educational purposes only. We do not own or affiliate with OpenAI and/or any of its subsidiaries in any form. Copyright Disclaimer Under section 107 of the Copyright Act 1976, allowance is made for β€œfair use” of this video for educational purposes. #nextjs #nextjs15 #react #ai #chatgpt #reactjs #coding #javascript #tailwindcss #shadcn #openai #reactjstutorial #coding #tutorial #beginner #programming #machinelearning #story #aiagents

You May Also Like

Upgrade Your Tech Today

AI-recommended products based on this video

Loading...
SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

(3)
$411.98
Delivery Wednesday, June 11.
Loading...
USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

(5,196)
$9.89
FREE delivery Sun, Sep 21 on $35 of items shipped by Amazon
10K+ bought in past month
Loading...
Megoo 14" Laptop Sleeve Case for Surface Laptop 7/6/5/4/Studio, Surface Book, Samsung Galaxy Tab S9/S8, Shockproof Water-Resistant Carry Pouch Bag for 13.5"-14.6" Notebook Computers(Light Gray)

Megoo 14" Laptop Sleeve Case for Surface Laptop 7/6/5/4/Studio, Surface Book, Samsung Galaxy Tab S9/S8, Shockproof Water-Resistant Carry Pouch Bag for 13.5"-14.6" Notebook Computers(Light Gray)

(1)
11.89
PrimeFREE delivery Saturday, June 14 on orders shipped by Amazon over $35
Loading...
SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

(3)
$411.98
Delivery Wednesday, June 11.
Loading...
Wireless Bluetooth Mouse for Apple iPad iPhone MacBook Android Samsung Tablet Phone Dual-Mode Rechargeable 2.4G Portable Computer Mice for Windows Laptop Notebook PC Mac Desktop USB Receiver (Black)

Wireless Bluetooth Mouse for Apple iPad iPhone MacBook Android Samsung Tablet Phone Dual-Mode Rechargeable 2.4G Portable Computer Mice for Windows Laptop Notebook PC Mac Desktop USB Receiver (Black)

(1,960)
9.99
PrimeFREE delivery Saturday, June 14 on orders shipped by Amazon over $35
500+ bought in past month
Loading...
USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

(5,196)
$9.89
FREE delivery Sun, Sep 21 on $35 of items shipped by Amazon
10K+ bought in past month
Loading...
SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

(3)
$411.98
Delivery Wednesday, June 11.
Loading...
USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

(5,196)
$9.89
FREE delivery Sun, Sep 21 on $35 of items shipped by Amazon
10K+ bought in past month
Loading...
Megoo 14" Laptop Sleeve Case for Surface Laptop 7/6/5/4/Studio, Surface Book, Samsung Galaxy Tab S9/S8, Shockproof Water-Resistant Carry Pouch Bag for 13.5"-14.6" Notebook Computers(Light Gray)

Megoo 14" Laptop Sleeve Case for Surface Laptop 7/6/5/4/Studio, Surface Book, Samsung Galaxy Tab S9/S8, Shockproof Water-Resistant Carry Pouch Bag for 13.5"-14.6" Notebook Computers(Light Gray)

(1)
11.89
PrimeFREE delivery Saturday, June 14 on orders shipped by Amazon over $35
Loading...
SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

(3)
$411.98
Delivery Wednesday, June 11.
Loading...
ANKER 737 Power Bank, 24,000mAh 3-Port Laptop Portable Charger with 140W Fast Charging, Smart Display, for Outdoor Work, Compatible with iPhone 16/15/14 Series, Vision Pro, Samsung, MacBook, and More

ANKER 737 Power Bank, 24,000mAh 3-Port Laptop Portable Charger with 140W Fast Charging, Smart Display, for Outdoor Work, Compatible with iPhone 16/15/14 Series, Vision Pro, Samsung, MacBook, and More

(13,939)
109.99
FREE delivery Saturday, June 14
9K+ bought in past month
Loading...
Anker Power Bank(PowerCore 10K),Compact Travel-Ready 10,000mAh Battery Pack with PowerIQ Charging Technology,5V/3A High-Speed Charging for iPhone,iPad,and More (USB-C Input and Output(BlackοΌ‰οΌŒ1pack) ClimatePartner certified

Anker Power Bank(PowerCore 10K),Compact Travel-Ready 10,000mAh Battery Pack with PowerIQ Charging Technology,5V/3A High-Speed Charging for iPhone,iPad,and More (USB-C Input and Output(BlackοΌ‰οΌŒ1pack) ClimatePartner certified

(109,961)
$17.99$17.81
FREE delivery Fri, Aug 8 on $35 of items shipped by Amazon
10K+ bought in past month
Loading...
DJI Mic Mini (2 TX + 1 RX + Charging Case), Wireless Lavalier Microphone for iPhone/Camera/Android, Ultralight, Detail-Rich Audio, 48h Use, Noise Cancelling, Automatic Limiting, Vlog, Streaming
Best Seller

DJI Mic Mini (2 TX + 1 RX + Charging Case), Wireless Lavalier Microphone for iPhone/Camera/Android, Ultralight, Detail-Rich Audio, 48h Use, Noise Cancelling, Automatic Limiting, Vlog, Streaming

(4,886)
$136.00$130.56
FREE delivery Thu, Sep 4
10K+ bought in past month
Loading...
2 Pack Continuous Spray Bottles - Ultra Fine Mist Sprayer | Water Spray Bottle For Hair Mister Spray Bottle | Hair Spray Bottles For Hairstyling, Cleaning, Salons - 2pk 6.8 OZ / 200 ML
Best Seller

2 Pack Continuous Spray Bottles - Ultra Fine Mist Sprayer | Water Spray Bottle For Hair Mister Spray Bottle | Hair Spray Bottles For Hairstyling, Cleaning, Salons - 2pk 6.8 OZ / 200 ML

(6,586)
$7.63
FREE delivery Mon, Jun 30 on $35 of items shipped by Amazon
30K+ bought in past month
Loading...
JSAUX 3-Pack Tempered Glass Screen Protector for Nintendo Switch 2 (2025), Easy to Install with Guiding Frame Ultra HD Glass Protector 9H Hardness Scratch Resistant Accessories for Switch2

JSAUX 3-Pack Tempered Glass Screen Protector for Nintendo Switch 2 (2025), Easy to Install with Guiding Frame Ultra HD Glass Protector 9H Hardness Scratch Resistant Accessories for Switch2

(178)
$7.58
FREE delivery Sun, Jun 15 on $35 of items shipped by Amazon
4K+ bought in past month
Loading...
Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

(126)
$8.99
FREE delivery Fri, Oct 3 on $35 of items shipped by Amazon
8K+ bought in past month
Loading...
Belkin BoostCharge Lightning Cable - 6.6ft/2M - MFi Certified Apple iPhone Charger USB to Lightning Cable - iPhone Cable - iPhone Charger Cord - Apple Charger - USB Phone Charger - Black

Belkin BoostCharge Lightning Cable - 6.6ft/2M - MFi Certified Apple iPhone Charger USB to Lightning Cable - iPhone Cable - iPhone Charger Cord - Apple Charger - USB Phone Charger - Black

(3,522)
11.99
PrimeFREE delivery Saturday, June 14 on orders shipped by Amazon over $35
100+ bought in past month
Loading...
Lexar ES3 1TB External SSD, USB 3.2 Gen2 Portable SSD, PSSD Up to 1050MB/s Read, 1000MB/s Write, External Solid State Drive Compatible with iPhone 16/15 Series/Mac/PS5/XBOX/Laptop/PC

Lexar ES3 1TB External SSD, USB 3.2 Gen2 Portable SSD, PSSD Up to 1050MB/s Read, 1000MB/s Write, External Solid State Drive Compatible with iPhone 16/15 Series/Mac/PS5/XBOX/Laptop/PC

(37)
69.99
PrimeFREE delivery Saturday, June 14
300+ bought in past month
Loading...
acer Aspire 3 Laptop | 15.6" FHD (1920 x 1080) Display | 8-Core AMD Ryzen 7-5700U | AMD Radeon | 64GB RAM | 4.5TB SSD (4TB PCIe SSD withHP P500 512GB Portable SSD) | Ethernet Port | Windows 11 Pro

acer Aspire 3 Laptop | 15.6" FHD (1920 x 1080) Display | 8-Core AMD Ryzen 7-5700U | AMD Radeon | 64GB RAM | 4.5TB SSD (4TB PCIe SSD withHP P500 512GB Portable SSD) | Ethernet Port | Windows 11 Pro

(3)
$979.99$739.99
FREE delivery Jun 18 - 23
Loading...
acer Aspire 3 Laptop | 15.6" FHD (1920 x 1080) Display | AMD Radeon | 8-Core AMD Ryzen 7-5700U | 64GB RAM | 4.5TB SSD (4TB PCIe SSD withHP P500 512GB Portable SSD) | Ethernet Port | Windows 11 Pro

acer Aspire 3 Laptop | 15.6" FHD (1920 x 1080) Display | AMD Radeon | 8-Core AMD Ryzen 7-5700U | 64GB RAM | 4.5TB SSD (4TB PCIe SSD withHP P500 512GB Portable SSD) | Ethernet Port | Windows 11 Pro

(14)
$979.99$739.99
FREE delivery Jun 18 - 23
Loading...
Anker USB C to USB C Cable, Type-C 60W Fast Charging Cable (6FT, 2Pack) for iPhone 16 Series, iPad mini 6 and More (Black) ClimatePartner certified
Best Seller

Anker USB C to USB C Cable, Type-C 60W Fast Charging Cable (6FT, 2Pack) for iPhone 16 Series, iPad mini 6 and More (Black) ClimatePartner certified

(44,096)
$8.49
FREE delivery Thu, Jul 3 on $35 of items shipped by Amazon
10K+ bought in past month
Loading...
2 Pack Continuous Spray Bottles - Ultra Fine Mist Sprayer | Water Spray Bottle For Hair Mister Spray Bottle | Hair Spray Bottles For Hairstyling, Cleaning, Salons - 2pk 6.8 OZ / 200 ML
Best Seller

2 Pack Continuous Spray Bottles - Ultra Fine Mist Sprayer | Water Spray Bottle For Hair Mister Spray Bottle | Hair Spray Bottles For Hairstyling, Cleaning, Salons - 2pk 6.8 OZ / 200 ML

(6,586)
$7.63
FREE delivery Mon, Jun 30 on $35 of items shipped by Amazon
30K+ bought in past month
Loading...
JSAUX 3-Pack Tempered Glass Screen Protector for Nintendo Switch 2 (2025), Easy to Install with Guiding Frame Ultra HD Glass Protector 9H Hardness Scratch Resistant Accessories for Switch2

JSAUX 3-Pack Tempered Glass Screen Protector for Nintendo Switch 2 (2025), Easy to Install with Guiding Frame Ultra HD Glass Protector 9H Hardness Scratch Resistant Accessories for Switch2

(178)
$7.58
FREE delivery Sun, Jun 15 on $35 of items shipped by Amazon
4K+ bought in past month
Loading...
Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

(126)
$8.99
FREE delivery Fri, Oct 3 on $35 of items shipped by Amazon
8K+ bought in past month
Loading...
Zima Dental Pod: Ultrasonic Retainer Cleaner. The Original Retainer Cleaner Machine, Aligner Cleaner, Nightguard Cleaner, Mouthguard Cleaner, Denture Cleaner. Ultrasonic Cleaner For Oral Dental Care

Zima Dental Pod: Ultrasonic Retainer Cleaner. The Original Retainer Cleaner Machine, Aligner Cleaner, Nightguard Cleaner, Mouthguard Cleaner, Denture Cleaner. Ultrasonic Cleaner For Oral Dental Care

(6,197)
$89.99
FREE delivery Sun, Dec 28
30K+ bought in past month
Loading...
2 Pack Continuous Spray Bottles - Ultra Fine Mist Sprayer | Water Spray Bottle For Hair Mister Spray Bottle | Hair Spray Bottles For Hairstyling, Cleaning, Salons - 2pk 6.8 OZ / 200 ML
Best Seller

2 Pack Continuous Spray Bottles - Ultra Fine Mist Sprayer | Water Spray Bottle For Hair Mister Spray Bottle | Hair Spray Bottles For Hairstyling, Cleaning, Salons - 2pk 6.8 OZ / 200 ML

(6,586)
$7.63
FREE delivery Mon, Jun 30 on $35 of items shipped by Amazon
30K+ bought in past month
Loading...
JSAUX 3-Pack Tempered Glass Screen Protector for Nintendo Switch 2 (2025), Easy to Install with Guiding Frame Ultra HD Glass Protector 9H Hardness Scratch Resistant Accessories for Switch2

JSAUX 3-Pack Tempered Glass Screen Protector for Nintendo Switch 2 (2025), Easy to Install with Guiding Frame Ultra HD Glass Protector 9H Hardness Scratch Resistant Accessories for Switch2

(178)
$7.58
FREE delivery Sun, Jun 15 on $35 of items shipped by Amazon
4K+ bought in past month
Loading...
Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

Hydrocolloid Bandages for Wound Care, Extra Large Medical-Grade Hydrocolloid Roll with Self-Adhesive, Ultra Absorbent, Flexible & Waterproof, DIY Size & Shape First Aid Kit Essential (2in*4.8ft)

(126)
$8.99
FREE delivery Fri, Oct 3 on $35 of items shipped by Amazon
8K+ bought in past month
Loading...
Zima Dental Pod: Ultrasonic Retainer Cleaner. The Original Retainer Cleaner Machine, Aligner Cleaner, Nightguard Cleaner, Mouthguard Cleaner, Denture Cleaner. Ultrasonic Cleaner For Oral Dental Care

Zima Dental Pod: Ultrasonic Retainer Cleaner. The Original Retainer Cleaner Machine, Aligner Cleaner, Nightguard Cleaner, Mouthguard Cleaner, Denture Cleaner. Ultrasonic Cleaner For Oral Dental Care

(6,197)
$89.99
FREE delivery Sun, Dec 28
30K+ bought in past month
Loading...
SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

SAMSUNG Galaxy Watch Ultra 47mm LTE AI Smartwatch Bundle w/ 25W Power Adapter, Energy Score, Wellness Tips, Heart Rate Tracking, Sleep Monitor, Fitness Tracker, GPS, 2024,Titanium Silver

(3)
$411.98
Delivery Wednesday, June 11.
Loading...
Megoo 14" Laptop Sleeve Case for Surface Laptop 7/6/5/4/Studio, Surface Book, Samsung Galaxy Tab S9/S8, Shockproof Water-Resistant Carry Pouch Bag for 13.5"-14.6" Notebook Computers(Light Gray)

Megoo 14" Laptop Sleeve Case for Surface Laptop 7/6/5/4/Studio, Surface Book, Samsung Galaxy Tab S9/S8, Shockproof Water-Resistant Carry Pouch Bag for 13.5"-14.6" Notebook Computers(Light Gray)

(1)
11.89
PrimeFREE delivery Saturday, June 14 on orders shipped by Amazon over $35
Loading...
USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

USB C Car Charger, 3-Port 67W Dual USB-C & USB-A Car Power Adapter PD/QC Fast Charging Cigarette Lighter for iPhone 17/16/15/14/13/12/11 Pro Max, iPad, Samsung Galaxy S25 S24/S23/S22, Pixel, Android

(5,196)
$9.89
FREE delivery Sun, Sep 21 on $35 of items shipped by Amazon
10K+ bought in past month