
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@standardbeagle/data-router
Advanced tools
A memory-only, XPath-based router for React that operates with data structures instead of URLs. Perfect for complex React components that need internal routing and data manipulation without interfering with the parent application's routing system.
A memory-only, XPath-based router for React that operates with data structures instead of URLs. Perfect for complex React components that need internal routing and data manipulation without interfering with the parent application's routing system.
npm install @standardbeagle/data-router
import { DataProvider, useXPath, useData, Link, Form, Button } from '@standardbeagle/data-router';
// Initialize with some data
const initialData = {
users: [
{ id: 1, name: 'John', profile: { email: 'john@example.com' } }
],
settings: { theme: 'light' }
};
function App() {
return (
<DataProvider initialData={initialData} initialXPath="/users[0]">
<UserProfile />
</DataProvider>
);
}
function UserProfile() {
const xpath = useXPath(); // "/users[0]"
const targetData = useTargetData(); // { id: 1, name: 'John', profile: {...} }
return (
<div>
<h1>Current Location: {xpath}</h1>
<p>User: {targetData.name}</p>
{/* Navigate to user's profile */}
<Link to="profile">View Profile</Link>
{/* Navigate to settings */}
<Link to="/settings">Go to Settings</Link>
{/* Form to update user data */}
<Form targetXPath="/users[0]" operation="merge">
<input name="name" defaultValue={targetData.name} />
<Button dataAction="merge">Update User</Button>
</Form>
</div>
);
}
/users[0]/profile/emailprofile/settings (relative to current XPath).. (go up one level), ../.. (go up two levels)Provides the data context and routing state.
<DataProvider
initialData={myData}
initialXPath="/users[0]"
>
{children}
</DataProvider>
Navigate to different XPaths (read-only navigation).
<Link to="/users[1]">Go to User 1</Link>
<Link to="../settings">Go to Settings</Link>
Wrap form elements for data manipulation.
<Form targetXPath="/users[0]" operation="merge">
<input name="email" />
<Button dataAction="merge">Save</Button>
</Form>
Submit button with data manipulation capabilities.
<Button
dataAction="replace"
targetXPath="/settings/theme"
navigateTo="/settings"
>
Update Theme
</Button>
useXPath() - Get current XPathuseData() - Get entire data objectuseTargetData() - Get data at current XPathuseNavigate() - Get navigation functionuseDataManipulation() - Get data manipulation functionsISC
FAQs
A memory-only, XPath-based router for React that operates with data structures instead of URLs. Perfect for complex React components that need internal routing and data manipulation without interfering with the parent application's routing system.
The npm package @standardbeagle/data-router receives a total of 2 weekly downloads. As such, @standardbeagle/data-router popularity was classified as not popular.
We found that @standardbeagle/data-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.