@@ -2,6 +2,7 @@ import { isClerkAPIResponseError } from '@clerk/shared/error';
22import { useClerk , useOrganization , useUser } from '@clerk/shared/react' ;
33import type { CreateAPIKeyParams } from '@clerk/shared/types' ;
44import { lazy , useState } from 'react' ;
5+ import { useSWRConfig } from 'swr' ;
56import useSWRMutation from 'swr/mutation' ;
67
78import { useProtect } from '@/ui/common' ;
@@ -72,7 +73,14 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
7273 data : createdApiKey ,
7374 trigger : createApiKey ,
7475 isMutating,
75- } = useSWRMutation ( cacheKey , ( _key , { arg } : { arg : CreateAPIKeyParams } ) => clerk . apiKeys . create ( arg ) ) ;
76+ } = useSWRMutation (
77+ {
78+ ...cacheKey ,
79+ action : 'create' ,
80+ } ,
81+ ( _key , { arg } : { arg : CreateAPIKeyParams } ) => clerk . apiKeys . create ( arg ) ,
82+ ) ;
83+ const { mutate : mutateApiKeys } = useSWRConfig ( ) ;
7684 const { t } = useLocalizations ( ) ;
7785 const [ isRevokeModalOpen , setIsRevokeModalOpen ] = useState ( false ) ;
7886 const [ selectedApiKeyId , setSelectedApiKeyId ] = useState ( '' ) ;
@@ -85,6 +93,7 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
8593 ...params ,
8694 subject,
8795 } ) ;
96+ void mutateApiKeys ( cacheKey ) ;
8897 card . setError ( undefined ) ;
8998 setIsCopyModalOpen ( true ) ;
9099 } catch ( err : any ) {
0 commit comments