daton-template-snippet
v0.0.14
Published
native javascript app to authenticate users
Downloads
6
Keywords
Readme
Get started with Daton Template Snippet
Install Daton Template Snippet
First, we will need to add Daton template snippet file in your frontend.
Add the following script tag in your website:
<script type="text/javascript" src="https://unpkg.com/daton-template-snippet@latest/dist/daton-template-snippet.js"></script>
The script injects a global Daton variable in the window object.
Initiate the Daton template API:
Then, on any HTML template, on either click of a button or any other event, you can initiate the Daton template API.
<!DOCTYPE html>
<html>
<head>
<title>Sample HTML Template</title>
</head>
<body>
<p><button onclick="loadDaton()">Load Daton!</button></p>
</body>
</html>
<script type="text/javascript" src="https://unpkg.com/daton-template-snippet@latest/dist/daton-template-snippet.js"></script>
<script type="text/javascript">
function loadDaton() {
window.Daton.init({
apiKey: "<API_KEY>",
baseSourceName: "<SOURCE_NAME>",
newSourceNamePrefix: "<PREFIX>"
});
}
</script>
onSuccess and onError callbacks
You can also pass onSuccess and onError callbacks to the init function.
function loadDaton() {
window.Daton.init({
apiKey: "<API_KEY>",
baseSourceName: "<SOURCE_NAME>",
newSourceNamePrefix: "<PREFIX>",
onSuccess: () => {
console.log("success")
},
onError: (err) => {
console.log("error")
}
});
}
Development
To run the project locally, run the following command:
npm run start
Build
To build the project, run the following command:
npm run build
To publish the package
To publish the package, run the following command:
- Update the version in package.json
- Run the following command:
npm publish --access public
- Go to https://www.npmjs.com/package/daton-template-snippet and check if the package is published successfully.