Skip to main content
This guide walks through integrating Jupiter Plugin into a React application from scratch. It covers TypeScript declarations, embedding the plugin script, and two initialization methods: the window object approach and the @jup-ag/plugin npm package.

Prerequisites

Before you begin, make sure you have the following installed on your system. Node.js and npm: Download and install from nodejs.org

Step 1: Create a New React Project

Head to your preferred directory and create a new React project using create-react-app with TypeScript template (you can use other templates or methods to start your project too):

Step 2: Add TypeScript Support

Create a type declaration file plugin.d.ts in your project’s /src/types folder:

Step 3: Embed the Plugin Script

In your /public/index.html, add the Jupiter Plugin script:

Step 4: Initialize Plugin

There are two ways to initialize Jupiter Plugin in a React application:

Method 1: Using Window Object

In your /src/App.tsx, use the following code to initialize the plugin.

Method 2: Using @jup-ag/plugin Package

WARNINGDo note that using this method will require you to maintain its dependencies.
1
Install the package:
2
Initialize the plugin:
There you have it! You’ve successfully integrated Jupiter Plugin into your Next.js application.
  • Please test the swap functionality and check the transaction.
  • If you require more customizations, check out the Plugin Playground or the Customization documentation.
  • If you have any questions or issues, please refer to the FAQ or contact us on Discord.