@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.orgStep 1: Create a New Next.js Project
Head to your preferred directory and create a new Next.js project usingcreate-next-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 fileplugin.d.ts in your project’s /src/types folder:
Full TypeScript Declaration
Full TypeScript Declaration
Step 3: Embed the Plugin Script
For Next.js applications, you can add the script in two ways:Using App Router (Next.js 13+)
In yourapp/layout.tsx:
Using Pages Router
In yourpages/_app.tsx:
Step 4: Initialize Plugin
There are two ways to initialize Jupiter Plugin in a Next.js application:Method 1: Using Window Object
Create a new component for the plugin atcomponents/plugin.tsx:
Method 2: Using @jup-ag/plugin Package
1
Install the package:
2
Create a new component for the plugin at
components/plugin.tsx:Step 5: Add the Plugin Component to Your Page
In yourapp/page.tsx (or pages/index.tsx if you’re using Pages Router):
- 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.
