useOrganization
Read the organization identifier supplied to OrganizationProvider, returning the id string or undefined if unset.
useOrganization returns the organization identifier provided to OrganizationProvider. Use it to reach organization-level services, such as organization settings or users, through backend.organization(id).
Basic usage
import { useBackendStrict, useOrganization } from "@gooddata/sdk-ui";
function MyComponent() {
const backend = useBackendStrict();
const organization = useOrganization();
if (!organization) {
return <div>No organization configured</div>;
}
// Access organization-level services
const orgService = backend.organization(organization);
// ...
}
Parameters
None.
Return value
string | undefined: the organization identifier, or undefined when no OrganizationProvider up the tree sets one.
Notes
- Components re-render when
OrganizationProviderreceives a neworganizationvalue. - There is no strict variant. If your code can’t work without an organization, check for
undefinedand render a fallback or throw, as in the example. - The hook only returns the identifier; it makes no backend call. Combine it with a backend, for example from
useBackendStrict, to load organization resources.
Related
Retrieve the analytical backend from BackendProvider context, with an optional prop override or strict variant.
Read the workspace identifier from WorkspaceProvider context, with an optional override and a strict variant that throws when unset.
Embed the internal Automations list at workspace or organization scope, configure its filters and columns, and handle individual or bulk actions.