Skip to main content
Jarallax can be seamlessly integrated into React and Next.js applications using custom wrapper components. This guide shows you how to build reusable components and handle server-side rendering.

Installation

First, install Jarallax in your React or Next.js project:

React Component Setup

Create reusable React components for Jarallax functionality:
1

Create the Jarallax Component

Build a wrapper component that manages the parallax lifecycle:
components/Jarallax.js
This component properly handles initialization, cleanup, and prop updates to prevent memory leaks.
2

Create the Image Component

Create a simple component for parallax images:
components/JarallaxImage.js
3

Use in Your Application

Import and use the components in your React app:
App.js

Next.js Integration

Next.js requires special handling due to server-side rendering (SSR). Jarallax needs to run only on the client side.

Basic Next.js Setup

Here’s how to integrate Jarallax in a Next.js application:
pages/index.js
Always use dynamic import with { ssr: false } for the Jarallax component to prevent server-side rendering issues.

App Router Setup (Next.js 13+)

For Next.js App Router, mark your component as a Client Component:
components/Jarallax.js

Advanced Next.js Example

Here’s a complete example with dynamic state management and interactive controls:
pages/index.js
This advanced example demonstrates how to dynamically add, remove, and update parallax blocks with different configurations in real-time.

Common Props

The Jarallax component accepts all standard Jarallax options as props:

Video Backgrounds in React

Enable video backgrounds by ensuring the video extension is initialized:

Styling

Add CSS to control the appearance and layout:
styles/globals.css

TypeScript Support

Jarallax includes TypeScript definitions. Create typed components:
components/Jarallax.tsx

Performance Optimization

Lazy load parallax components for better initial page load:

Troubleshooting

Ensure you’re using dynamic import with { ssr: false } for the Jarallax component. The library requires browser APIs that aren’t available during server-side rendering.
Make sure you’re properly handling prop changes in the useEffect hook. The component should destroy and reinitialize Jarallax when props change:
Always clean up Jarallax instances in the useEffect cleanup function:

Next Steps

Vanilla JavaScript

Learn basic Jarallax usage without frameworks

jQuery Integration

Use Jarallax with jQuery

API Reference

Explore all available methods and options

Configuration

Advanced configuration options