@zitadel/sdk-react 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/chunk-QJALWXNY.js +22 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +19 -0
- package/dist/react.d.ts +32 -0
- package/dist/react.js +8 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ZITADEL
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @zitadel/sdk-react
|
|
2
|
+
|
|
3
|
+
React components for the Zitadel auth UI, for client-side SPAs.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import {
|
|
9
|
+
ZitadelLogin,
|
|
10
|
+
ZitadelLogout,
|
|
11
|
+
configureZitadel,
|
|
12
|
+
} from '@zitadel/sdk-react';
|
|
13
|
+
|
|
14
|
+
// Configure once, before rendering. The handle is passed to the widget as a
|
|
15
|
+
// prop, so it has config the moment it mounts.
|
|
16
|
+
const project = configureZitadel({
|
|
17
|
+
projectId: '<your project id>', // e.g. from your bundler's env (import.meta.env, process.env, …)
|
|
18
|
+
proxyPath: '/__nextgen', // same-origin path your deploy proxies to the backend
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export function LoginPage() {
|
|
22
|
+
return <ZitadelLogin project={project} purpose="login" postSignInUrl="/" />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function ProfilePage() {
|
|
26
|
+
return <ZitadelLogout project={project} postSignOutUrl="/login" />;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Proxying to the backend (deployment)
|
|
31
|
+
|
|
32
|
+
The widgets call `${proxyPath}/…` same-origin (default `/__nextgen`). A SPA has no
|
|
33
|
+
server, so on Vercel (and Cloudflare/Netlify) use `@zitadel/edge-proxy` to forward
|
|
34
|
+
those calls to your Zitadel backend:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// api/__nextgen/[...path].ts (Vercel Edge Function)
|
|
38
|
+
import { handleProxy, resolveConfig } from '@zitadel/edge-proxy';
|
|
39
|
+
|
|
40
|
+
export const config = { runtime: 'edge' };
|
|
41
|
+
const proxyConfig = resolveConfig({
|
|
42
|
+
apiUrl: process.env.NEXTGEN_API_URL ?? '',
|
|
43
|
+
});
|
|
44
|
+
export default (req: Request) => handleProxy(req, proxyConfig);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
// vercel.json
|
|
49
|
+
{
|
|
50
|
+
"rewrites": [
|
|
51
|
+
{ "source": "/__nextgen/(.*)", "destination": "/api/__nextgen/$1" }
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For local development you can skip the proxy entirely and point `proxyPath` straight
|
|
57
|
+
at the backend (cross-origin), e.g. `proxyPath: "http://localhost:4000"`.
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// src/react.tsx
|
|
2
|
+
import { createComponent } from "@lit/react";
|
|
3
|
+
import {
|
|
4
|
+
ZitadelLogin as ZitadelLoginElement,
|
|
5
|
+
ZitadelLogout as ZitadelLogoutElement
|
|
6
|
+
} from "@zitadel/components";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
var ZitadelLogin = createComponent({
|
|
9
|
+
react: React,
|
|
10
|
+
tagName: "zitadel-login",
|
|
11
|
+
elementClass: ZitadelLoginElement
|
|
12
|
+
});
|
|
13
|
+
var ZitadelLogout = createComponent({
|
|
14
|
+
react: React,
|
|
15
|
+
tagName: "zitadel-logout",
|
|
16
|
+
elementClass: ZitadelLogoutElement
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
ZitadelLogin,
|
|
21
|
+
ZitadelLogout
|
|
22
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ZitadelLogin, ZitadelLogout } from './react.js';
|
|
2
|
+
export { ZitadelConfig, ZitadelProject, configureZitadel, getApi, getZitadelConfig } from '@zitadel/api/config';
|
|
3
|
+
export { AuthResult, AuthState, NextgenMiddlewareOptions, NextgenSession, UnauthState } from '@zitadel/sdk-core/types';
|
|
4
|
+
import '@lit/react';
|
|
5
|
+
import '@zitadel/components';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ZitadelLogin,
|
|
3
|
+
ZitadelLogout
|
|
4
|
+
} from "./chunk-QJALWXNY.js";
|
|
5
|
+
import "./chunk-6F4PWJZI.js";
|
|
6
|
+
|
|
7
|
+
// src/index.ts
|
|
8
|
+
import {
|
|
9
|
+
configureZitadel,
|
|
10
|
+
getApi,
|
|
11
|
+
getZitadelConfig
|
|
12
|
+
} from "@zitadel/api/config";
|
|
13
|
+
export {
|
|
14
|
+
ZitadelLogin,
|
|
15
|
+
ZitadelLogout,
|
|
16
|
+
configureZitadel,
|
|
17
|
+
getApi,
|
|
18
|
+
getZitadelConfig
|
|
19
|
+
};
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as _lit_react from '@lit/react';
|
|
2
|
+
import { ZitadelLogin as ZitadelLogin$1, ZitadelLogout as ZitadelLogout$1 } from '@zitadel/components';
|
|
3
|
+
import '@zitadel/api/config';
|
|
4
|
+
import '@zitadel/sdk-core/types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* React components for the Zitadel auth widgets.
|
|
8
|
+
*
|
|
9
|
+
* These wrap the framework-agnostic Lit web components from
|
|
10
|
+
* `@zitadel/components` with `@lit/react`'s `createComponent`, so they are real
|
|
11
|
+
* React components: typed props, refs, and events, with the SDK `project`
|
|
12
|
+
* handle bound as a DOM *property* (not an attribute) — which is what the
|
|
13
|
+
* elements read at startup.
|
|
14
|
+
*
|
|
15
|
+
* In a client-side SPA, build the handle with `configureZitadel(...)` and pass
|
|
16
|
+
* it as the `project` prop. Because the SPA renders after configuration, the
|
|
17
|
+
* prop is present when the element upgrades:
|
|
18
|
+
*
|
|
19
|
+
* ```tsx
|
|
20
|
+
* import { ZitadelLogin, configureZitadel } from "@zitadel/sdk-react";
|
|
21
|
+
*
|
|
22
|
+
* const project = configureZitadel({ projectId: "…", proxyPath: "/__nextgen" });
|
|
23
|
+
*
|
|
24
|
+
* export function LoginPage() {
|
|
25
|
+
* return <ZitadelLogin project={project} purpose="login" postSignInUrl="/" />;
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare const ZitadelLogin: _lit_react.ReactWebComponent<ZitadelLogin$1, {}>;
|
|
30
|
+
declare const ZitadelLogout: _lit_react.ReactWebComponent<ZitadelLogout$1, {}>;
|
|
31
|
+
|
|
32
|
+
export { ZitadelLogin, ZitadelLogout };
|
package/dist/react.js
ADDED
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AuthResult, AuthState, NextgenMiddlewareOptions, NextgenSession, UnauthState } from '@zitadel/sdk-core/types';
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./chunk-6F4PWJZI.js";
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zitadel/sdk-react",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "React components for the Zitadel auth UI (client-side SPA).",
|
|
5
|
+
"homepage": "https://github.com/zitadel/nextgen/tree/main/packages/sdk-react#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/zitadel/nextgen/issues"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/zitadel/nextgen.git",
|
|
13
|
+
"directory": "packages/sdk-react"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@lit/react": "^1.0.8",
|
|
30
|
+
"@zitadel/components": "0.1.0-alpha.0",
|
|
31
|
+
"@zitadel/api": "0.1.0-alpha.0",
|
|
32
|
+
"@zitadel/sdk-core": "0.1.0-alpha.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"react": ">=18",
|
|
36
|
+
"react-dom": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@eslint/js": "^9.0.0",
|
|
40
|
+
"@testing-library/react": "^16.3.2",
|
|
41
|
+
"@types/react": "^19.2.14",
|
|
42
|
+
"eslint": "^9.0.0",
|
|
43
|
+
"jsdom": "^29.0.2",
|
|
44
|
+
"react": "^19.2.5",
|
|
45
|
+
"react-dom": "^19.2.5",
|
|
46
|
+
"tsup": "^8.3.5",
|
|
47
|
+
"typescript": "^5.7.3",
|
|
48
|
+
"vitest": "^3.0.0",
|
|
49
|
+
"@eslint/json": "^0.11.0",
|
|
50
|
+
"@eslint/markdown": "^6.0.0",
|
|
51
|
+
"eslint-config-prettier": "^10.0.0",
|
|
52
|
+
"eslint-import-resolver-typescript": "^3.7.0",
|
|
53
|
+
"eslint-plugin-import": "^2.31.0",
|
|
54
|
+
"eslint-plugin-perfectionist": "^4.0.0",
|
|
55
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
56
|
+
"prettier": "^3.0.0",
|
|
57
|
+
"typescript-eslint": "^8.0.0",
|
|
58
|
+
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
59
|
+
"eslint-plugin-react": "^7.37.0",
|
|
60
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
61
|
+
"eslint-plugin-testing-library": "^7.0.0"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsup src/index.ts src/react.tsx src/types.ts --format esm --dts --clean --tsconfig tsconfig.json --external react react-dom",
|
|
65
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
66
|
+
"test": "vitest run --passWithNoTests",
|
|
67
|
+
"lint": "eslint ."
|
|
68
|
+
}
|
|
69
|
+
}
|