Is it possible to detect reenter or back button in POS UI extension?

Hi @Alan_G,

thanks for your statement.

I tried to describe in Navigation API (2025-10): data flow between screens how I currently try to handle screens in my current project.

I try to summarize it a bit.

modal.js - acts as router

function Extension() {
  const { url } = navigation.currentEntry

  if (url === '/TransferDetail') {
    return <TransferDetail />
  }

  if (url === '/TransferDetailItem') {
    return <TransferDetailItem />
  }

  return <TransferSelection />
}

Pass a callback function to the state object of navigation.navigate().
The screen which uses this state uses the callback to notify about a change.

const state = navigation.currentEntry.getState()
const {
  calllback,
} = state

callback()
const [timestamp, setTimestamp] = useState(Date.now()) // to force re-render on line item transfer update

useEffect(() => {
  foo()
}, [timestamp])

return <>
  {lineItems.map((lineItem) => (
    <s-clickable for={lineItem.id} onClick={() => {
      navigation.navigate('/TransferDetailItem', {
        state: {
          callback: () => {
            setTimestamp(Date.now())
          },
        },
      })
    )}>
      <s-text>{lineItem.id}</s-text>
    </s-clickable>
  })}
</>

I’m aware of the limitations (Navigation API).
I know that non-serializable data of type function is passed to the navigation state.

But it works!
And I don’t see what can happen doing so.
I understand that function isn’t serializable. But I don’t know the impact of this fact.

And: I really try to avoid usage of complex state management like Redux.

So what are my risks?