DriveLoader Logo
DriveLoaderv1.2.0

Examples & Recipes Gallery

Explore copy-pasteable code examples for images, videos, public folder galleries, custom hooks, and cache management.

media

Universal <DriveMedia /> Auto-Detector

One single component automatically detects whether the Google Drive link is an image, video, audio track, or PDF document.

universal-media.tsx
1import { DriveMedia } from '@driveloader/react';
2
3export function UniversalAsset({ driveUrl }: { driveUrl: string }) {
4 return (
5 <DriveMedia
6 src={driveUrl}
7 alt="Dynamic Media Asset"
8 controls
9 />
10 );
11}
audio

Google Drive Audio & Playlist Player

Stream Google Drive hosted audio files with custom waveform visualization canvas and multi-track playlists.

audio-playlist.tsx
1import { DriveAudio, DrivePlaylist } from '@driveloader/react';
2
3export function PodcastPlayer() {
4 return (
5 <DrivePlaylist
6 tracks={[
7 { src: 'https://drive.google.com/file/d/AUDIO_1/view', title: 'Episode 1: Intro', artist: 'DriveLoader' },
8 { src: 'https://drive.google.com/file/d/AUDIO_2/view', title: 'Episode 2: Deep Dive', artist: 'DriveLoader' }
9 ]}
10 />
11 );
12}
document

PDF & Document Viewer (<DriveDocument />)

Preview PDFs, Google Docs, text files, and Markdown directly inside React apps with zoom and download controls.

document-viewer.tsx
1import { DriveDocument } from '@driveloader/react';
2
3export function DocumentReader({ docUrl }: { docUrl: string }) {
4 return (
5 <DriveDocument
6 src={docUrl}
7 height="600px"
8 width="100%"
9 />
10 );
11}
portfolio

Portfolio & Photography Website

High-performance masonry photo gallery with skeleton placeholders, lazy loading, and failover endpoints.

portfolio-photography.tsx
1import { DriveGallery } from '@driveloader/react';
2
3export function PhotographyPortfolio({ photoUrls }: { photoUrls: string[] }) {
4 return (
5 <DriveGallery
6 images={photoUrls}
7 columns={{ sm: 1, md: 2, lg: 3 }}
8 gap="1.5rem"
9 />
10 );
11}
nextjs

Next.js App Router Loader (createDriveNextLoader)

Pass a custom loader to Next.js <Image /> component for optimized server-side rendering and CDN delivery.

nextjs-app-router.tsx
1import Image from 'next/image';
2import { createDriveNextLoader } from '@driveloader/react';
3
4const driveLoader = createDriveNextLoader();
5
6export function ProfileAvatar({ src }: { src: string }) {
7 return (
8 <Image
9 loader={driveLoader}
10 src={src}
11 alt="User Profile"
12 width={300}
13 height={300}
14 priority
15 />
16 );
17}
vite

Vite & React Router Single Page App

Seamless single page application integration with instant client-side resolution and LRU memory caching.

vite-react-router.tsx
1import { DriveImage, DriveVideo } from '@driveloader/react';
2
3export function ViteApp() {
4 return (
5 <main className="p-8">
6 <DriveImage src="https://drive.google.com/file/d/IMG_ID/view" alt="Vite Demo" />
7 <DriveVideo src="https://drive.google.com/file/d/VID_ID/view" controls />
8 </main>
9 );
10}
video

Course Platform & Video Player

Video course streaming platform featuring automatic poster thumbnails and video metadata extraction.

course-platform.tsx
1import { DriveVideo, useDriveVideo } from '@driveloader/react';
2
3export function LessonPlayer({ lessonUrl }: { lessonUrl: string }) {
4 const { metadata, loading } = useDriveVideo(lessonUrl);
5
6 return (
7 <div>
8 <DriveVideo src={lessonUrl} controls autoPlay={false} />
9 {!loading && <p>Lesson Length: {metadata?.duration} seconds</p>}
10 </div>
11 );
12}
image

Basic Image Component

Render Google Drive images with skeletons, fade-in transitions, and automatic fallback endpoints.

basic-image.tsx
1import { DriveImage } from '@driveloader/react';
2
3export function Avatar() {
4 return (
5 <DriveImage
6 src="https://drive.google.com/file/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs/view"
7 alt="User Avatar"
8 width={120}
9 height={120}
10 fade={true}
11 />
12 );
13}
folder

Public Folder Explorer

Fetch all images and videos from a public Google Drive folder using Google Drive API v3 with pagination.

folder-loader.tsx
1import { useDriveFolder, DriveImage } from '@driveloader/react';
2
3export function FolderView({ folderUrl, apiKey }: { folderUrl: string; apiKey: string }) {
4 const { folder, assets, loading, loadMore, hasMore } = useDriveFolder({
5 folderUrl,
6 apiKey,
7 mediaTypes: ['image', 'video', 'audio', 'document'],
8 pageSize: 20,
9 });
10
11 return (
12 <div>
13 <h3>{folder?.name}</h3>
14 <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '1rem' }}>
15 {assets.map(asset => (
16 <DriveImage key={asset.id} src={asset.resolvedUrl} alt={asset.name} />
17 ))}
18 </div>
19 {hasMore && <button onClick={loadMore}>Load More</button>}
20 </div>
21 );
22}
devtools

Developer Debugger HUD (<DriveDebugOverlay />)

Expose real-time telemetry, cache hits, resolution latency, and candidate endpoints during development.

devtools-hud.tsx
1import { DriveDebugOverlay } from '@driveloader/react';
2
3export function App() {
4 return (
5 <main>
6 <YourAppContent />
7 {process.env.NODE_ENV === 'development' && <DriveDebugOverlay />}
8 </main>
9 );
10}