2022-08-25 09:03:07 +00:00
# Keycloak Admin UI
2024-07-05 16:48:10 +00:00
This project is the next generation of the Keycloak Admin UI. It is written with React and [PatternFly 4 ](https://www.patternfly.org/v4/ ) and uses [Vite ](https://vitejs.dev/guide/ ).
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
## Features
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
Contains all the "pages" from the admin-ui as re-usable components, all the functions to save and the side menu to use in your own build of the admin-ui
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
## Install
2022-08-25 09:03:07 +00:00
```bash
2024-07-05 16:48:10 +00:00
npm i @keycloak/keycloak -admin-ui
2022-08-25 09:03:07 +00:00
```
2024-07-05 16:48:10 +00:00
## Usage
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
To use these pages you'll need to add `KeycloakProvider` in your component hierarchy to setup what client, realm and url to use.
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
```jsx
import { KeycloakProvider } from "@keycloak/keycloak-ui-shared";
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
//...
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
< KeycloakProvider environment = {{
authServerUrl: "http://localhost:8080",
realm: "master",
clientId: "security-admin-console"
}}>
{/* rest of you application */}
< / KeycloakProvider >
2022-08-25 09:03:07 +00:00
```
2024-07-05 16:48:10 +00:00
### Translation
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
For the translation we use `react-i18next` you can [set it up ](https://react.i18next.com/ ) as described on their website.
If you want to use the translations that are provided then you need to add `i18next-http-backend` to your project and add:
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
```ts
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
backend: {
loadPath: `http://localhost:8180/resources/master/admin/{{lng}}` ,
parse: (data: string) => {
const messages = JSON.parse(data);
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
const result: Record< string , string > = {};
messages.forEach((v) => (result[v.key] = v.value));
return result;
},
},
2022-08-25 09:03:07 +00:00
```
2024-07-05 16:48:10 +00:00
to the `i18next` config object.
2022-12-01 14:19:06 +00:00
2024-07-05 16:48:10 +00:00
## Building
2022-08-25 09:03:07 +00:00
2024-07-05 16:48:10 +00:00
To build a library instead of an app you need to add the `LIB=true` environment variable.
2022-08-25 09:03:07 +00:00
```bash
2024-07-05 16:48:10 +00:00
LIB=true pnpm run build
```