React hooks to use inside a <Refine> component configured with the auth provider of @activitypods/refine-providers. They require @refinedev/core 5 and @tanstack/react-query 5.
useAuthProvider
Return the auth provider given to Refine, with its additional methods. It throws an error if it wasn’t created with @activitypods/refine-providers.
const session = useAuthProvider().getSession();
useCollection
Fetch an ActivityPub collection. See Inbox & outbox for an example.
The Pod providers to offer, as { 'apods:baseUrl': string, 'apods:area'?: string } objects
redirect
String
/
Where to go once logged in
Without any of the first two options, the hook fetches the public Pod providers matching the current locale.
Return value
Property
Type
Description
isProcessing
Boolean
true while the OIDC flow is being completed. Display a loader or the error
error
String
The error to display
podProviders
Array
The Pod providers to offer
login
Function
Redirect to the given Pod provider
backToLogin
Function
Go back to the list of Pod providers
Search params
Param
Description
?signup
Go through the signup form of the Pod provider when logging in
?iss=<url>
Log in directly to this Pod provider
?logout
Log out the user
?redirect=<path>
Where to go once logged in. It takes precedence over the redirect option
?code
Complete the OIDC flow. Added by the Pod provider
?register_app
Check that the app is registered. Added by the hook
useBackgroundChecks
Check the app status while the user is logged in, to build your own version of the BackgroundChecks component. Checks are done regularly and whenever the tab becomes visible again.
If the app is not registered or if its access needs changed, the user is redirected to the authorization screen of the Pod provider. When they come back, the hook returns to the page they were on.
Options
Property
Type
Default
Description
listeningTo
Array
[]
URIs on which the app backend must have a webhook channel
checkInterval
Number | false
120000
Interval in ms between checks. With false, there is no periodic check
Return value
Property
Type
Description
isLoggedOut
Boolean
true if the user is not logged in
isChecked
Boolean
true once a check has succeeded
error
String
The error to display if the backend is offline, doesn’t listen to the URIs, or if the check failed
retry
Function
Check again
useResourceRedirect
Handle the links coming from the data browser of the Pod provider. The boilerplate uses it on the /r route, which is advertised as the resource_url in its nodeinfo.
useResourceRedirect({ resources, jsonContext });
Parameters
Parameter
Type
Default
Description
resources
Object
required
The same value as for the data provider
jsonContext
Any
ActivityStreams’ context
The same value as for the data provider
Search params
The hook finds the Refine resource matching the type param, then redirects:
Params
Redirects to
?type=<type>&uri=<uri>
The show page of the resource
?type=<type>&uri=<uri>&mode=edit
The edit page of the resource
?type=<type>
The list page of the resource
Unknown or missing type
The homepage
Translations
The hooks translate their texts with the i18nProvider given to Refine, using these keys and default texts: