MoonGate SDK
A beautiful, customizable Solana wallet adapter built with React and shadcn/ui components.
Features
- đ¨ Fully Customizable - Brand colors, logo, and wallet selection
- đ Easy Integration - Single provider component
- đ Comprehensive Wallet Support - 30+ wallet adapters included
- đź TypeScript First - Full type safety
- đŻ Modern UI - Built with shadcn/ui components
- ⥠Optimized - Tree-shakable and performant
Installation
npm install moongate-sdk
yarn add moongate-sdk
pnpm add moongate-sdk
CSS Styles
The SDK includes scoped CSS styles that won't interfere with your application's styles. Import the CSS file in your app:
import 'moongate-sdk/styles.css';
Important: The SDK uses advanced CSS scoping with the tailwindcss-scoped-preflight plugin to prevent style conflicts. All Tailwind base styles, utilities, and custom styles are automatically scoped to .moongate-wallet-sdk containers.
Quick Start
1. Wrap your app with MoonGateProvider
import { MoongateConnectButton, MoonGateProvider } from 'moongate-sdk';
const config = {
primaryColor: '#9945FF',
secondaryColor: '#14F195',
logo: '/your-logo.svg',
wallets: {
primary: [
{ name: 'Phantom', order: 1 },
{ name: 'Solflare', order: 2 },
],
secondary: [
{ name: 'WalletConnect', order: 1 },
{ name: 'Coinbase Wallet', order: 2 },
{ name: 'Ledger', order: 3 },
],
},
};
function App() {
return (
<MoonGateProvider config={config}>
<div>
<h1>My Solana App</h1>
<MoongateConnectButton />
</div>
</MoonGateProvider>
);
}
2. Use wallet functionality in your components
import { useWallet, useWalletModal } from 'moongate-sdk';
function MyComponent() {
const { connected, publicKey, disconnect } = useWallet();
const { setVisible, config } = useWalletModal();
if (!connected) {
return <button onClick={() => setVisible(true)}>Connect Wallet</button>;
}
return (
<div>
<p>Connected: {publicKey?.toString()}</p>
<button onClick={disconnect}>Disconnect</button>
</div>
);
}
Configuration
AdapterConfig
interface AdapterConfig {
primaryColor: string;
secondaryColor: string;
logo: string;
wallets: WalletConfig;
}
WalletConfig
interface WalletConfig {
primary: WalletItem[];
secondary?: WalletItem[];
}
interface WalletItem {
name: string;
order: number;
}
Supported Wallets
- Phantom
- Solflare
- WalletConnect
- Coinbase Wallet
- Ledger
- Burner Wallet
- And 25+ more...
MoonGateProvider Props
interface MoonGateProviderProps {
children: ReactNode;
config: AdapterConfig;
network?: WalletAdapterNetwork;
endpoint?: string;
autoConnect?: boolean;
}
Example Configurations
Minimal Setup
const minimalConfig = {
primaryColor: '#000000',
secondaryColor: '#666666',
logo: '/logo.svg',
wallets: {
primary: [{ name: 'Phantom', order: 1 }],
},
};
Custom Branding
const customConfig = {
primaryColor: '#FF6B6B',
secondaryColor: '#4ECDC4',
logo: '/custom-logo.svg',
wallets: {
primary: [
{ name: 'Phantom', order: 1 },
{ name: 'Solflare', order: 2 },
],
secondary: [
{ name: 'WalletConnect', order: 1 },
{ name: 'Ledger', order: 2 },
],
},
};
Components
MoongateConnectButton
The main wallet connection button with built-in state management.
import { MoongateConnectButton } from 'moongate-sdk';
<MoongateConnectButton />;
Hooks
useWalletModal
Access wallet modal state and configuration.
const { visible, setVisible, config } = useWalletModal();
useWallet (re-exported)
Standard Solana wallet adapter hook.
const { connected, publicKey, disconnect, sendTransaction } = useWallet();
useConnection (re-exported)
Access the Solana connection.
const { connection } = useConnection();
Advanced Usage
Custom Network
import { WalletAdapterNetwork } from 'moongate-sdk';
<MoonGateProvider config={config} network={WalletAdapterNetwork.Mainnet}>
{children}
</MoonGateProvider>;
Custom RPC Endpoint
<MoonGateProvider config={config} endpoint="https://your-rpc-endpoint.com">
{children}
</MoonGateProvider>
TypeScript Support
The SDK is built with TypeScript and provides full type safety:
import type { AdapterConfig, WalletConfig, WalletName } from 'moongate-sdk';
CSS Scoping & Style Isolation
The MoonGate SDK uses advanced CSS scoping techniques to ensure complete style isolation from your application. This prevents any conflicts between the SDK's styles and your existing CSS.
How It Works
- Scoped Container: All SDK components are automatically wrapped in a
.moongate-wallet-sdk container
- Scoped Base Styles: Tailwind's base styles (normalize, box-sizing, etc.) are scoped using
tailwindcss-scoped-preflight
- Prefixed Utilities: All Tailwind CSS utilities are scoped using the
important selector
- Custom Variables: CSS custom properties are namespaced with
--moongate- prefix
- Complete Isolation: No global styles affect your application
Implementation Details
<MoonGateProvider config={config}>
<YourApp /> {}
</MoonGateProvider>
<ScopedPortal>
<WalletModal /> {/* Also wrapped in .moongate-wallet-sdk */}
</ScopedPortal>
CSS Variables
The SDK uses scoped CSS variables that won't conflict with your app:
.moongate-wallet-sdk {
--moongate-background: 0 0% 100%;
--moongate-foreground: 240 10% 3.9%;
--moongate-primary: 240 5.9% 10%;
}
Benefits
- â
Zero Style Conflicts: Your app's styles remain untouched
- â
Consistent Theming: SDK maintains its design system
- â
Easy Integration: No need to modify your existing CSS
- â
Framework Agnostic: Works with any CSS framework or methodology
Troubleshooting
If you experience style conflicts:
- Ensure you're importing the CSS:
import "moongate-sdk/styles.css"
- Check that the
.moongate-wallet-sdk class is present on SDK components
- Verify your bundler is processing the CSS correctly
Custom Styling
While the SDK is fully scoped, you can still customize it by targeting the scoped classes:
.moongate-wallet-sdk .your-custom-overrides {
}
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
MIT License - see LICENSE for details.