sh
sh
NNuxt
Created by sh on 6/10/2024 in #❓・help
Using Nuxt's Router with @zitadel/vue
Here is the code
import { createZITADELAuth } from "@zitadel/vue";
import { User } from 'oidc-client';

export default defineNuxtPlugin(async () => {
const zitadelAuth = createZITADELAuth({
project_resource_id: "resource_id",
client_id: "clientid@project",
issuer: "https://provider.zitadel.cloud/",
});

const ok = await zitadelAuth.oidcAuth.startup();

if (!ok) {
throw new Error("oidc startup failed");
} else {
console.info("Zitadel Auth initialized");

const router = useRouter();

zitadelAuth.oidcAuth.useRouter(router);

console.log(router)

return {
provide: {
zitadel: zitadelAuth
}
}
}
});
import { createZITADELAuth } from "@zitadel/vue";
import { User } from 'oidc-client';

export default defineNuxtPlugin(async () => {
const zitadelAuth = createZITADELAuth({
project_resource_id: "resource_id",
client_id: "clientid@project",
issuer: "https://provider.zitadel.cloud/",
});

const ok = await zitadelAuth.oidcAuth.startup();

if (!ok) {
throw new Error("oidc startup failed");
} else {
console.info("Zitadel Auth initialized");

const router = useRouter();

zitadelAuth.oidcAuth.useRouter(router);

console.log(router)

return {
provide: {
zitadel: zitadelAuth
}
}
}
});
2 replies