{"id":18772739,"url":"https://github.com/sctg-development/turnstile-vue3","last_synced_at":"2025-12-13T07:30:14.003Z","repository":{"id":260335171,"uuid":"880987663","full_name":"sctg-development/turnstile-vue3","owner":"sctg-development","description":"A Vue3 wrapper for Cloudflare Turnstile, providing a seamless integration of the Turnstile widget into your Vue3 application.","archived":false,"fork":false,"pushed_at":"2024-11-03T15:14:03.000Z","size":33,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T08:22:07.467Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sctg-development.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-30T18:07:14.000Z","updated_at":"2024-12-06T12:35:31.000Z","dependencies_parsed_at":"2024-12-29T08:21:45.535Z","dependency_job_id":"46ae9828-7947-4f1c-8488-e63c924f5ec5","html_url":"https://github.com/sctg-development/turnstile-vue3","commit_stats":null,"previous_names":["sctg-development/turnstile-vue3"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fturnstile-vue3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fturnstile-vue3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fturnstile-vue3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sctg-development%2Fturnstile-vue3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sctg-development","download_url":"https://codeload.github.com/sctg-development/turnstile-vue3/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239681025,"owners_count":19679508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T19:30:02.568Z","updated_at":"2025-12-13T07:30:13.926Z","avatar_url":"https://github.com/sctg-development.png","language":"Vue","funding_links":["https://github.com/sponsors/sctg-development"],"categories":["Vue"],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/@sctg%2Fturnstile-vue3.svg)](https://badge.fury.io/js/@sctg%2Fturnstile-vue3)\n[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)\n[![build](https://github.com/sctg-development/turnstile-vue3/actions/workflows/publish-npm.yml/badge.svg)](https://github.com/sctg-development/turnstile-vue3/actions/workflows/publish-npm.yml)\n\n# Turnstile Vue3 Component\n\nA Vue3 component for integrating Cloudflare Turnstile into your application.\n\n## Star the project\n\n**If you appreciate my work, please consider giving it a star! 🤩 or a** [![](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/sctg-development)\n\n## Installation\n\nTo install the Turnstile Vue3 component, run the following command:\n\n```bash\nnpm install @sctg/turnstile-vue3\n```\n\n## Usage\n\nHere is an example of how to use the Turnstile Vue3 component in your Vue3 application using the Composition API:\n\n```html\n\u003cscript setup lang=\"ts\"\u003e\nimport { Turnstile } from '@sctg/turnstile-vue3';\n\nconst siteKey = 'YOUR_SITE_KEY';\nconst handleSuccess = (token: string) =\u003e {\n    // Verify the token on your server using the verifyCaptcha function\n    fetch('/api/verify-captcha', {\n        method: 'POST',\n        headers: {\n            'Content-Type': 'application/json',\n        },\n        body: JSON.stringify({ token }),\n    })\n        .then((response) =\u003e response.json())\n        .then((data) =\u003e console.log(data))\n        .catch((error) =\u003e console.error(error));\n};\n\n\u003c/script\u003e\n\n\u003ctemplate\u003e\n    \u003cdiv\u003e\n        \u003cTurnstile :site-key=\"siteKey\" @complete=\"handleSuccess\" /\u003e\n    \u003c/div\u003e\n\u003c/template\u003e\n```\n\n## Verify Captcha on Server\n\nYou can verify the captcha token on your server using the verifyCaptcha function:\n\n```javascript\nimport express from 'express';\nimport { verifyCaptcha } from '@sctg/turnstile-vue3';\n\nconst app = express();\napp.use(express.json());\n\napp.post('/api/verify-captcha', (req, res) =\u003e {\n    const { token } = req.body;\n    const turnstileSecret = 'YOUR_TURNSTILE_SECRET';\n\n    verifyCaptcha(turnstileSecret, token, req.ip)\n        .then((data) =\u003e {\n            if (data.success) {\n                res.json({ message: 'Captcha verified successfully' });\n            } else {\n                res.status(401).json({ message: 'Invalid captcha' });\n            }\n        })\n        .catch((error) =\u003e {\n            res.status(500).json({ message: 'Error verifying captcha' });\n        });\n});\n\napp.listen(3000, () =\u003e {\n    console.log('Server started on port 3000');\n});\n```\n\n## Cloudflare Worker Sample\n\nHere is an example of how to use the verifyCaptcha function in a Cloudflare worker:\n\n```javascript\nimport { verifyCaptcha } from '@sctg/turnstile-vue3';\n\naddEventListener('fetch', (event) =\u003e {\n    event.respondWith(handleRequest(event.request));\n});\n\nasync function handleRequest(request) {\n    const { url, method } = request;\n    if (method === 'POST' \u0026\u0026 url.pathname === '/verify-captcha') {\n        const { token } = await request.json();\n        const turnstileSecret = 'YOUR_TURNSTILE_SECRET';\n\n        try {\n            const data = await verifyCaptcha(turnstileSecret, token, request.ip);\n            if (data.success) {\n                return new Response('Captcha verified successfully', { status: 200 });\n            } else {\n                return new Response('Invalid captcha', { status: 401 });\n            }\n        } catch (error) {\n            return new Response('Error verifying captcha', { status: 500 });\n        }\n    }\n\n    return new Response('Method not allowed', { status: 405 });\n}\n```\n\n### API\n\nThe `Turnstile` component has the following props:\n\n* `siteKey`: The site key for your Turnstile account.\n* `modelValue`: The initial value for the Turnstile token.\n* `resetInterval`: The interval (in milliseconds) before the Turnstile is reset. Default is 295000 (5 minutes).\n* `size`: The size of the Turnstile widget. Can be one of the following:\n\n  * `normal`: The default size.\n  * `flexible`: A flexible size that adapts to the container.\n  * `compact`: A compact size that is smaller than the default size.\n\n* `theme`: The theme of the Turnstile widget. Can be one of the following:\n\n  * `light`: A light theme.\n  * `dark`: A dark theme.\n  * `auto`: Automatically detects the theme based on the surrounding environment.\n\n* `language`: The language of the Turnstile widget. Can be one of the following:\n\n  * `auto`: Automatically detects the language based on the surrounding environment.\n  * A valid language code (e.g., `en`, `fr`, `es`, etc.).\n\n* `action`: The action that the Turnstile widget is verifying. Can be any string.\n* `appearance`: The appearance of the Turnstile widget. Can be one of the following:\n\n  * `always`: Always shows the Turnstile widget.\n  * `execute`: Shows the Turnstile widget only when the user interacts with the element.\n  * `interaction-only`: Shows the Turnstile widget only when the user interacts with the element, and hides it when the interaction is completed.\n\n* `renderOnMount`: Whether to render the Turnstile widget when the component is mounted. Default is `true`.\n* `v-model`: A two-way binding for the Turnstile token.\n\nThe `Turnstile` component emits the following events:\n\n* `update:modelValue`: Updates the `modelValue` prop with the new Turnstile token.\n* `complete`: Emitted when the Turnstile challenge is completed successfully.\n* `error`: Emitted when an error occurs.\n* `unsupported`: Emitted when the Turnstile widget is not supported.\n* `expired`: Emitted when the Turnstile widget has expired.\n* `before-interactive`: Emitted when the Turnstile widget is about to become interactive.\n* `after-interactive`: Emitted when the Turnstile widget becomes interactive.\n\n## License\n\nThis project is licensed under the AGPLv3 license.\n\n## Contributing\n\nContributions to this library are welcome! Please open an issue or submit a pull request for any changes you'd like to make.\n\n## Disclaimer\n\nThis library is not affiliated with Cloudflare. It's just a convenient wrapper around the Turnstile API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsctg-development%2Fturnstile-vue3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsctg-development%2Fturnstile-vue3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsctg-development%2Fturnstile-vue3/lists"}