This guide will walk you through the process of integrating the Para Modal into a Vite-powered React application, providing a seamless way to manage user authentication and wallets.

If you haven’t already created a new Vite project, you can follow the official Vite docs to get started.

Prerequisites

To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration.

Don’t have an API key yet? Request access to the Developer Portal to create API keys, manage billing, teams, and more.

Installing Dependencies

First, install the Para React SDK and React Query using your preferred package manager:

npm install @getpara/react-sdk @tanstack/react-query

Setting Up Polyfills with Vite

Some Node.js modules that Para relies on (e.g., crypto, buffer, stream) may need to be polyfilled in a Vite environment. One easy option is to use vite-plugin-node-polyfills:

npm install vite-plugin-node-polyfills --save-dev
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { nodePolyfills } from "vite-plugin-node-polyfills";

export default defineConfig({
  plugins: [react(), nodePolyfills()],
  // Additional Vite configurations if needed
});

This ensures Node-specific modules are properly polyfilled in the browser environment.

Setting Up the Para SDK

1

Create a Providers Component

Create a providers component that will wrap your application with both the QueryClientProvider (required for Para) and the ParaProvider:

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { Environment, ParaProvider } from "@getpara/react-sdk";
import "@getpara/react-sdk/styles.css";

const queryClient = new QueryClient();

export function Providers({ children }) {
  return (
    <QueryClientProvider client={queryClient}>
      <ParaProvider
        paraClientConfig={{
          apiKey: import.meta.env.VITE_PARA_API_KEY || "",
          env: Environment.BETA,
        }}>
        {children}
      </ParaProvider>
    </QueryClientProvider>
  );
}

Para offers two hosted environments: Environment.BETA (alias Environment.DEVELOPMENT) for testing, and Environment.PROD (alias Environment.PRODUCTION) for live use. Select the environment that matches your current development phase.

2

Wrap Your App with Providers

Now, wrap your main app component with the Providers component:

import { Providers } from './providers';
import YourApp from './YourApp';

function App() {
  return (
    <Providers>
      <YourApp />
    </Providers>
  );
}

export default App;
3

Add the Para Modal

Now you can include the ParaModal component in any component within your application and use the ParaProvider hooks to control it:

import { ParaModal, useModal } from "@getpara/react-sdk";

function LoginButton() {
  const { openModal } = useModal();

  return (
    <>
      <button onClick={() => openModal()}>
        Sign in with Para
      </button>

      <ParaModal
        appName="Your App Name"
        logo="/logo.png"
      />
    </>
  );
}

export default LoginButton;

The ParaModal will automatically connect to the ParaProvider context, so you don’t need to pass any additional props for functionality. You only need to customize its appearance.

Beta Testing Credentials In the BETA Environment, you can use any email ending in @test.getpara.com (like dev@test.getpara.com) or US phone numbers (+1) in the format (area code)-555-xxxx (like (425)-555-1234). Any OTP code will work for verification with these test credentials. These credentials are for beta testing only. You can delete test users anytime in the beta developer console to free up user slots.

Customizing the Para Modal

To provide the best experience for your users, you can customize the appearance of the Para Modal to match your application’s branding.

When rendering the ParaModal component, you can pass props to customize its appearance:

<ParaModal
  appName="Your App Name"
  logo="/logo.png"
  theme={{ backgroundColor: "#ffffff", foregroundColor: "#000000" }}
  oAuthMethods={["GOOGLE", "TWITTER", "DISCORD"]}
/>

For a full list of available ParaModalProps, refer to the customization guide:

Alternative Approach: Standalone Para Modal

Examples

For practical implementation of the Para SDK in Vite-based React applications, explore our example repository. This repository contains real-world examples to help you get started.

Troubleshooting

If you encounter issues during the integration or usage of the Para Modal in a Vite-based app, here are some common problems and their solutions:

Next Steps

After integrating Para, you can explore other features and integrations to enhance your Para experience.