Skip to main content

configuration

Configuration

The Router Widget SDK (router-widget-sdk) is configured via a single config object passed to the RouterWidget component.

Required Parameters

The config object is optional, but you should set an integrator identifier.

import { RouterWidget } from 'router-widget-sdk';
import 'router-widget-sdk/styles.css';

<RouterWidget config={{ integrator: 'MyDApp' }} />;

Swap Configuration

Configure initial swap parameters using config.initialState.

Config PathTypeDescription
initialState.fromChainIdstringDefault source chain ID (e.g. '1')
initialState.fromTokenAddressstringDefault source token address ('native' or zero-address supported)
initialState.toChainIdstringDefault destination chain ID
initialState.toTokenAddressstringDefault destination token address

Swap Configuration Examples

Set default tokens:

<RouterWidget
config={{
initialState: {
fromChainId: '137',
fromTokenAddress: '0x0000000000000000000000000000000000000000',
},
}}
/>;

Theme Configuration

Customize the widget's appearance using config.theme.

Config PathTypeOptionsDescription
theme.modestringlight, dark, autoWidget theme mode
theme.primaryColorstringHex colorPrimary brand color
theme.backgroundColorstringHex colorBackground color
theme.textColorPrimarystringHex colorPrimary text color
theme.textColorSecondarystringHex colorSecondary text color
theme.mutedColorstringHex colorMuted background color (cards/inputs)
theme.cardBorderRadiusstringCSS valueCard border radius (applied when isWidget: true)
theme.buttonBorderRadiusstringCSS valueButton border radius
theme.fontFamilystringCSS valueFont family

Theme Examples

Dark theme with custom colors:

<RouterWidget
config={{
theme: {
mode: 'dark',
primaryColor: '#b82877',
backgroundColor: '#1a1a1a',
textColorPrimary: '#ffffff',
textColorSecondary: '#cccccc',
},
}}
/>;

Light theme:

<RouterWidget config={{ theme: { mode: 'light', primaryColor: '#b82877' } }} />;

Border Configuration

Border radius is configured via config.theme.cardBorderRadius and config.theme.buttonBorderRadius.

Features Configuration

Toggle widget features using config.features.

Config PathTypeDescription
features.showHeaderbooleanShow or hide the widget header
features.isSrcDisabledbooleanDisable source chain/token selection
features.isDestDisabledbooleanDisable destination chain/token selection

Features Examples

Hide header:

<RouterWidget config={{ features: { showHeader: false } }} />;

Disable selectors:

<RouterWidget config={{ features: { isSrcDisabled: true, isDestDisabled: true } }} />;

Nodes Configuration

Select which nodes/bridges are available for routing using config.selectedNodes.

Config PathTypeDescription
selectedNodesstring[]List of node IDs to use for routing

Nodes Examples

Allow specific nodes:

<RouterWidget config={{ selectedNodes: ['router', 'stargate'] }} />;

Note: If not specified, all available nodes will be used for routing.

Settings Configuration

Configure additional widget settings.

Config PathTypeDescription
integratorstringIntegrator identifier for tracking and analytics
isWidgetbooleanEnable embedded-widget styling behavior
variant'normal' | 'wide' | 'drawer'Layout variant for the widget UI
wallet.onConnectClick() => voidConnect wallet handler for external wallet providers

Complete Configuration Example

import { RouterWidget, type WidgetConfig } from 'router-widget-sdk';
import 'router-widget-sdk/styles.css';

const config: WidgetConfig = {
theme: {
mode: 'dark',
primaryColor: '#e4357a',
backgroundColor: '#0a0a0a',
textColorPrimary: '#ffffff',
textColorSecondary: '#a0a0a0',
mutedColor: '#1a1a1a',
cardBorderRadius: '10px',
buttonBorderRadius: '4px',
fontFamily: 'Inter, sans-serif',
},
initialState: {
fromChainId: '1',
fromTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
toChainId: '137',
toTokenAddress: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
},
features: {
showHeader: true,
isSrcDisabled: false,
isDestDisabled: false,
},
integrator: 'your-app-name',
selectedNodes: ['router', 'stargate'],
isWidget: true,
};

export default function App() {
return <RouterWidget config={config} />;
}

Using the Widget Playground

The easiest way to explore options is using the Widget Playground, then mapping settings into the SDK config object.

  1. Customize your widget using the visual interface
  2. Preview your changes in real-time
  3. Copy values for variant, theme, feature, node, and initial state settings
  4. Integrate by passing those values into config

The playground provides a visual interface for all configuration options, making it easy to customize your widget without manually constructing URL parameters.

Security Considerations

  • Treat any API keys/secrets as sensitive
  • Prefer environment variables where applicable
  • Configure allowed domains in your Router dashboard (if/where required)

Next Steps