Skip to main content

Path Remapping Guide for React Plugins

Feature Overview

Path remapping allows you to customize external URLs while maintaining your plugin’s internal routing logic. Perfect for SEO-optimized URLs, branded paths, and multi-market operations.

Framework

React SDK v2 - Requires React with TanStack Query
React is Required: This guide covers path remapping for React-based TagadaPay plugins. All code examples use React hooks and patterns from the TagadaPay SDK v2.

What is Path Remapping?

Path remapping lets you expose custom, SEO-friendly URLs to your users while your plugin continues to use its original internal paths internally.

Example Scenario

Your plugin defines these internal paths:
But you want customers to see:
Path remapping makes this possible!

SEO Benefits

Use keyword-rich URLs like /buy-now instead of /checkout

Brand Consistency

Match URLs to your brand language across markets

A/B Testing

Test different URL structures without changing plugin code

Multi-Market

Localized URLs: /acheter (FR) vs /kaufen (DE) vs /checkout (EN)

How It Works

1

You configure the mapping in CRM

Tell TagadaPay: “When users visit /custom/:id, route to plugin’s /hello-with-param/:myparam
2

TagadaPay injects configuration

The platform automatically injects the mapping as a meta tag in your plugin’s HTML
3

SDK handles routing

The SDK transparently handles URL matching and parameter extraction
4

Your plugin works unchanged

Your code continues to use internal paths - no modifications needed!

Architecture

Configuration

In Plugin Manifest

Mark which pages support remapping:

In CRM (Done by Merchant)

Merchants configure remapping when mounting your plugin:

SDK Usage

Basic Routing with shouldMatchRoute()

What happens:
  • User visits: /buy-now (external URL)
  • SDK knows: “This is actually /checkout
  • shouldMatchRoute('/checkout') returns true
  • Your component renders correctly!

Parameter Extraction with matchRoute()

New in v2.7.14: matchRoute() extracts URL parameters from remapped paths automatically!
Example:

Getting Path Information with getPathInfo()

Real-World Examples

Example 1: E-commerce Checkout

Plugin defines:
Merchant wants:
Your plugin code (unchanged!):
Result: Works perfectly with both URL structures! ✅

Example 2: Thank You Page with Order ID

Plugin expects:
Merchant wants:
Your plugin code:

Example 3: Multi-Market Localization

Plugin internal paths:
Different markets:
Your plugin:
Each market configures their preferred external URL in the CRM. Your plugin works everywhere! 🌍

Example 4: Product Pages with Slugs

Plugin:
SEO-Friendly URLs:
Implementation:

Parameter Name Rules

Important: When remapping paths with parameters, parameter names must match between external and internal paths.

✅ Valid Remapping

Both use :myparamWorks!

❌ Invalid Remapping

Parameter names don’t match → CRM will reject this Why? This ensures reliable parameter extraction without complex name mapping logic.

Development & Testing

Local Development

Test path remapping in your local environment using localStorage:
Clear remapping:

Query Parameter Method

Alternative testing method:

Debugging

Add a debug component to see what’s happening:

Production Behavior

Automatic Meta Tag Injection

In production, TagadaPay automatically injects remapping configuration:
Decoded:
The SDK reads this automatically - no action needed from you!

CDN Distribution

Remapped plugins are served from CDN subdomains:

Best Practices

1. Always Use SDK Functions

Don’t parse window.location manually! Always use SDK functions for path matching.
❌ Don’t do this:
✅ Do this:

2. Mark Pages as Remappable

In your plugin.manifest.json:

3. Keep Internal Paths Descriptive

Even if merchants remap them, keep your internal paths clear: Good:
Avoid:

4. Handle Both Scenarios

Your plugin should work whether remapping is active or not:

5. Test Both Paths

During development, test your plugin with:
  1. Original paths: http://localhost:5173/checkout
  2. Remapped paths: Use localStorage to simulate remapping

API Reference

shouldMatchRoute(internalPath: string): boolean

Check if the current URL matches the given internal path. Parameters:
  • internalPath: Your plugin’s internal path pattern (e.g., /checkout, /product/:id)
Returns:
  • boolean: true if current URL matches (considering remapping), false otherwise
Example:

matchRoute(internalPath: string): RouteMatchResult

Check if route matches AND extract URL parameters. Parameters:
  • internalPath: Your plugin’s internal path pattern
Returns:
Example:

getPathInfo(): PathInfo

Get detailed information about the current path and remapping status. Returns:
Example:

getInternalPath(): string | null

Get the current internal path (or null if no remapping). Returns:
  • string: Internal path if remapping is active
  • null: If no remapping is active
Example:

Troubleshooting

Parameters are empty

Problem: matchRoute() returns { matched: true, params: {} } Solution: Ensure parameter names match in your manifest and CRM configuration:

Route not matching

Problem: shouldMatchRoute() returns false when it should match Checklist:
  1. Is the page marked as remappable: true in your manifest?
  2. Is the internal path correct (check with getPathInfo())?
  3. Are you using the SDK function (not window.location)?
  4. Try adding logging: console.log(getPathInfo())

Works locally but not in production

Problem: Remapping works in development but fails on CDN Solution:
  1. Check that meta tag is injected: View page source and search for tagadapay-path-remap
  2. Rebuild your plugin: pnpm build
  3. Redeploy: npx @tagadapay/plugin-cli deploy
  4. Clear browser cache and CDN cache

Remapping not working locally

Problem: localStorage remapping doesn’t work Solution:

Migration Guide

From Manual Routing

Before (manual routing):
After (SDK routing):

From React Router Params

Before:
After:

Advanced Patterns

Nested Routes with Remapping

Conditional Remapping Display

SEO Meta Tags with Remapping

Next Steps

API Reference

Complete SDK API documentation

Examples

Real-world plugin examples

Best Practices

Optimization tips and patterns

Tutorial

Build your first plugin

Need Help?