• Hook to access the ODD program and session from the OddContextProvider.

    It uses preact-router to handle routing, if your are using a different router you can use the useOddContext hook directly.

    It routes to the redirectTo path if the user is not logged in or when redirectIfFound is set to true routes to redirectTo if user is logged in.

    Example

    // login.jsx
    import { useOdd } from '@oddjs/preact/router'

    const { isLoading, login } = useOdd({
    redirectTo: '/',
    redirectIfFound: true,
    })

    Example

    // home.jsx
    import { useOdd } from '@oddjs/preact/router'

    const { isLoading, logout } = useOdd({
    redirectTo: '/login',
    })

    Parameters

    • options: {
          redirectIfFound?: boolean;
          redirectTo?: string;
      }
      • Optional redirectIfFound?: boolean
      • Optional redirectTo?: string

    Returns OddContext

Generated using TypeDoc