Navigation APIAPIs
APIs
The Navigation API enables POS UI extension to navigate between screens.
Supporting targets
() => void
required
Dismisses the extension.
(screenName: string, params?: any) => void
required
Navigate to a route in current navigation tree. Pushes the specified screen if it isn't present in the navigation tree, goes back to a created screen otherwise.
() => void
required
Pops the currently shown screen
Was this section helpful?
Anchor to examplesExamples
Examples of using the Navigation API
Was this section helpful?
Navigate between two screens
import React from 'react';
import {
reactExtension,
useApi,
Navigator,
Screen,
Button,
} from '@shopify/ui-extensions-react/point-of-sale';
const SmartGridModal = () => {
const api = useApi<'pos.home.modal.render'>();
return (
<Navigator>
<Screen name="ScreenOne" title="Screen One Title">
<Button
title="Navigate to Screen Two"
onPress={() => api.navigation.navigate('ScreenTwo')}
/>
</Screen>
<Screen name="ScreenTwo" title="Screen Two Title">
<Button
title="Navigate to Screen One"
onPress={() => api.navigation.navigate('ScreenOne')}
/>
</Screen>
</Navigator>
);
};
export default reactExtension('pos.home.modal.render', () => (
<SmartGridModal />
));
Was this section helpful?
Navigate to a route in current navigation tree
// You can navigate to any of these three screens since they all exist within the same Navigator.
return (
<Navigator>
<Screen name="ScreenOne" title="Screen One Title" />
<Screen name="ScreenTwo" title="Screen Two Title" />
<Screen name="ScreenThree" title="Screen Three Title" />
</Navigator>
);