Use CognitoPress like a pro — from dynamic shortcodes to secure API integrations.
This tutorial shows how to personalize your site using authentication state, display user data, and connect frontend JavaScript to protected endpoints.
CognitoPress provides shortcodes to embed login flows or show user info:
cognitopress
– load a pattern by ID, optionally override screen or variationcognitopress-attribute
– output a standard or custom user attributeCSS variables reflect user state and Cognito attributes:
--cognitopress-account-authenticated
--cognitopress-account-group-admin
--cognitopress-account-attribute-email
With a Professional plan, you can configure APIs in the plugin admin and use them from the frontend:
SmartCloud.cognito.get({
apiName: "backend",
path: "/some-protected-path"
}).then(res => console.log(res));
No need to manually attach tokens — the plugin handles authentication headers.
Use observeStore
to respond to login/logout transitions:
observeStore(
store,
(state) => state.signedIn,
async (signedIn, wasSignedIn) => {
if (wasSignedIn !== undefined) {
if (signedIn) {
// signed in
} else {
// signed out
}
}
}
);
The store
is globally available as SmartCloud.cognito.store
.
This guide covered how to extend CognitoPress with dynamic content, responsive design, and secure Cognito-based integrations.