This example app demonstrates all the features and capabilities of the @strv/react-native-hero-carousel library. It's built with Expo and showcases various carousel implementations, from basic auto-scrolling carousels to advanced video carousels with custom animations.
- Node.js (v18 or higher)
- yarn (recommended) or npm/pnpm
- Expo CLI
- iOS Simulator (macOS) or Android Emulator
-
Install dependencies
yarn install
-
Start the development server
yarn start
-
Run on your preferred platform
- iOS Simulator: Press
iin the terminal or scan QR with Expo Go - Android Emulator: Press
ain the terminal or scan QR with Expo Go - Physical Device: Install Expo Go and scan the QR code
- iOS Simulator: Press
The app includes a comprehensive set of examples demonstrating different carousel use cases:
| Example | Features | Best For |
|---|---|---|
| Basic Carousel | Auto-scrolling, infinite loop, image preloading | Simple hero sections, product showcases |
| Animated Carousel | Custom transitions, scale/rotation effects, pagination | Interactive galleries, feature highlights |
| Video Carousel | Video playback, play/pause controls, duration sync | Video showcases, tutorials, media content |
| Timer Pagination | Custom intervals per slide, visual progress | Announcements, promotional content |
| Entering Animation | Advanced slide entrance effects | Product launches, storytelling |
| Offset Example | Custom slide spacing and positioning | Card layouts, content previews |
| Component | Description | Use Case |
|---|---|---|
| Basic Pagination | Simple dot indicators | Standard navigation indicators |
| Timer Pagination | Animated progress bars | Visual timing feedback |
- Seamless video playback with
expo-video - Auto-scroll synced with video duration
- Play/pause controls with gesture support
- Background video management
- Scale, rotation, and opacity transitions
- Parallax effects using
interpolateInsideCarousel - Entrance animations for slides
- Smooth gesture-based navigation
- Dynamic intervals per slide
- Visual progress indicators
- Pause/resume on user interaction
- Custom timing functions
- Image preloading for smooth transitions
- Memoized components for better performance
- Efficient gesture handling
- Worklet-based animations for 60fps
example/
├── app/ # App router configuration
│ ├── (examples)/ # Example screens
│ │ ├── basic.tsx # Basic carousel route
│ │ ├── animated.tsx # Animated carousel route
│ │ ├── video-carousel.tsx # Video carousel route
│ │ └── ... # Other example routes
│ └── _layout.tsx # Root layout
├── examples/ # Example implementations
│ ├── BasicExample.tsx # Basic carousel implementation
│ ├── AnimatedExample.tsx # Animated carousel with custom transitions
│ ├── VideoCarouselExample.tsx # Video carousel implementation
│ ├── components/ # Reusable example components
│ │ ├── Pagination.tsx # Basic pagination component
│ │ └── TimerPagination.tsx # Timer pagination component
│ └── utils.ts # Shared utilities
└── hooks/ # Custom hooks for examples
└── useActiveSlideEffect.ts # Hook for managing active slide effects
- Create the example component in
examples/YourExample.tsx - Add a route in
app/(examples)/your-example.tsx - Update the navigation in
app/(examples)/_layout.tsx - Test on multiple platforms (iOS, Android, Web)
Example template:
// examples/YourExample.tsx
import { HeroCarousel, CarouselContextProvider } from '@strv/react-native-hero-carousel'
export default function YourExample() {
return (
<CarouselContextProvider interval={3000} disableAutoScroll={false} initialIndex={0}>
<HeroCarousel>{/* Your slides */}</HeroCarousel>
</CarouselContextProvider>
)
}The example app includes custom hooks that you can reference:
useActiveSlideEffect- Manage side effects when slides become active/inactiveuseIsActiveSlide- Determine if the current slide is activeuseColorScheme- Handle light/dark theme switching
- Smooth scrolling on all platforms
- Auto-scroll timing is consistent
- User interaction properly pauses auto-scroll
- Video playback works correctly
- Pagination indicators update in real-time
- Performance is smooth (60fps animations)
- Memory usage is reasonable (no leaks)
- Profile with Flipper - Monitor frame rates and memory usage
- Test on low-end devices - Ensure smooth performance
- Memory profiling - Check for memory leaks with video content
Metro bundler issues:
yarn start --clear-cacheiOS build issues:
cd ios && pod install && cd ..Android build issues:
yarn android --clearVideo not playing:
- Check network connection
- Verify video URLs are accessible
- Ensure
expo-videois properly configured
- Reduce image sizes if scrolling is choppy
- Enable Hermes for better JavaScript performance
- Use development builds instead of Expo Go for better performance
- Profile with React DevTools to identify bottlenecks
- Main README - Complete API documentation
- Source Code - Library implementation details
Found a bug or want to add a new example? Contributions are welcome!
- Fork the repository
- Create a feature branch
- Add your example or fix
- Test on multiple platforms
- Submit a pull request
This example app is part of the @strv/react-native-hero-carousel library and is licensed under the MIT License.
Made with ❤️ by STRV 🚀