Function API only Updated 30 May 2026
deleteJwt()
The deleteJwt function is responsible for removing the current (if any) JWT (JSON Web Token) secure cookie from the user's browser.
Parameters
This function takes no parameters.
Returns
True if successful.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Log out!</title>
</head>
<body style="font-size:2em; text-align:center; font-family: arial; margin-top:2em;">
<div id="message">You are now logging out! ⏳</div>
<a style="display:none" id="link1" href="/">Log in again</a>
<script>
// Static logout page. Hash templates are cached, so the actual
// cookie removal must happen in an API endpoint that calls
// docly.deleteJwt(). This page just fetches that endpoint.
fetch('/API/logout')
.then(response => response.json())
.then(data => {
document.getElementById('message').innerText = 'You are now logged out!';
document.getElementById('link1').style.display = '';
})
.catch(error => {
document.getElementById('message').innerText = 'Error during logout: ' + error.message;
console.error('Error:', error);
});
</script>
</body>
</html>The template above produces this output:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Log out!</title>
</head>
<body style="font-size:2em; text-align:center; font-family: arial; margin-top:2em;">
<div id="message">You are now logging out! ⏳</div>
<a style="display:none" id="link1" href="/">Log in again</a>
<script>
// Static logout page. Hash templates are cached, so the actual
// cookie removal must happen in an API endpoint that calls
// docly.deleteJwt(). This page just fetches that endpoint.
fetch('/API/logout')
.then(response => response.json())
.then(data => {
document.getElementById('message').innerText = 'You are now logged out!';
document.getElementById('link1').style.display = '';
})
.catch(error => {
document.getElementById('message').innerText = 'Error during logout: ' + error.message;
console.error('Error:', error);
});
</script>
</body>
</html>Normal JavaScript, running in the browser or on the Docly™ server.
// Log a user out by removing their JWT cookie
docly.deleteJwt();
// Typical use in a logout API endpoint:
// #/API/logout.js
export default () => {
docly.deleteJwt();
return { success: true };
}
// Note: deleteJwt() removes a custom JWT cookie set by writeJwt().
// To log a user out of the built-in Docly session, use docly.logOut() instead.