NextGen js request: logout action and event

Classic knack had Knack.logout(); which let you easily log out a user, e.g. when they click a custom button. This was useful if you built your own nav bar or had other reasons to log the user out and wanted to make that happen via js.

It doesn’t seem there is any such js api to initiate a logout with NextGen, but there should be!

Also, it would be great to have an event that fires when a user is logged out successfully e.g. Knack.on(‘logout’ => { ….. some code …. }); so that you could either redirect the user to a custom page or run some other code (e.g. clear the cookie from Intercom or similar chat widget).

Hey @jake5, there’s no current way to log out via JS in Next-Gen, but we’re pushing for it!

Regarding an event listener for a user signing out, it was just announced in this week’s update email (subscribe here).

Here’s the code:

Knack.on('user:signout', ({ user, pathname }) => {
  console.log("User:", user);
  console.log("Last page:", pathname);
  window.location.href = '#home'
});