Skip to content

API Reference / @gtkx/navigation / getStateFromPath

Function: getStateFromPath()

getStateFromPath<ParamList>(path, options?): ResultState | undefined

Defined in: node_modules/.pnpm/@react-navigation+core@7.21.13_react@19.2.8/node_modules/@react-navigation/core/lib/typescript/src/getStateFromPath.d.ts:32

Utility to parse a path string to initial state object accepted by the container. This is useful for deep linking when we need to handle the incoming URL.

Type Parameters

ParamList

ParamList extends object

Parameters

path

string

Path string to parse and convert, e.g. /foo/bar?count=42.

options?

Options<ParamList>

Extra options to fine-tune how to parse the path.

Returns

ResultState | undefined

Example

js
getStateFromPath(
  '/chat/jane/42',
  {
    screens: {
      Chat: {
        path: 'chat/:author/:id',
        parse: { id: Number }
      }
    }
  }
)

Released under the MPL-2.0 License.