index.ts 971 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { ConfigContext } from '@/providers/config'
  2. import { ConnectionContext } from '@/providers/connection'
  3. import { DocumentContext } from '@/providers/document'
  4. import { SessionContext } from '@/providers/session'
  5. import { useContext } from 'react'
  6. export { useRouteSearch } from './routeSearch'
  7. /** Get remote configuration. */
  8. export function useConfig() {
  9. return useContext(ConfigContext)
  10. }
  11. /**
  12. * Get the connection to the Herda server.
  13. * This provides access to request options such as base URL, authentication etc.
  14. */
  15. export function useConnection() {
  16. return useContext(ConnectionContext)
  17. }
  18. /**
  19. * Get functions to modify the document, including setting the page title.
  20. */
  21. export function useDocument() {
  22. return useContext(DocumentContext)
  23. }
  24. /**
  25. * Get the user session, using the connection authentication.
  26. * This also provides functions to verify and manage the session.
  27. */
  28. export function useSession() {
  29. return useContext(SessionContext)
  30. }