-
Notifications
You must be signed in to change notification settings - Fork 460
feat(nuxt,vue): Introduce Nuxt SDK #4541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
41871bf
feat(nuxt): Add Nuxt package
wobsoriano 390eadf
chore(nuxt): Update imports
wobsoriano 270e467
chore(nuxt): Add more comments
wobsoriano a61ee47
fix(vue,nuxt): type exports
wobsoriano 7cfe2e6
chore: add changeset
wobsoriano 4001ffe
chore(nuxt): Add @clerk/types to dev deps
wobsoriano 9d63caa
chore(nuxt): Add more helpful comments
wobsoriano 04dfc6a
chore(nuxt): Rename main entrypoint for more clarity
wobsoriano 83f5ea2
chore(nuxt): Add comment about bundling
wobsoriano a04966a
chore(nuxt,vue): Add dev script
wobsoriano 83bc234
chore(nuxt,vue): Directly import error thrower from utils
wobsoriano 480bcca
chore(nuxt): Add Nuxt v4 support
wobsoriano 8ff765c
chore(nuxt): Revert version
wobsoriano 487827e
chore(nuxt): Add README and LICENSE
wobsoriano bd75cba
chore(nuxt): Update README
wobsoriano 384b5d2
chore(nuxt): Update README
wobsoriano 545ab28
chore(nuxt): Use global variables for module name and version
wobsoriano 9c9723f
chore(nuxt): Fix dependencies
wobsoriano d600929
chore: Reinstall deps with pnpm
wobsoriano 763eefa
chore(nuxt): Replace npx command with pnpm dlx
wobsoriano 313a20b
chore(nuxt): Fix vue version and remove unused export
wobsoriano efd300e
chore(nuxt): Fix missing dependencies required by pnpm
wobsoriano 7f4d72b
chore: simplify tsconfig
wobsoriano ec8284f
Update packages/nuxt/README.md
wobsoriano 86262db
chore(nuxt): Remove unused dep
wobsoriano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@clerk/nuxt": patch | ||
| "@clerk/vue": patch | ||
| --- | ||
|
|
||
| Introduce an experimental version of Clerk SDK for [Nuxt](https://nuxt.com) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| module.exports = { | ||
| root: true, | ||
| extends: ['@clerk/custom/browser', '@clerk/custom/typescript'], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Dependencies | ||
| node_modules | ||
|
|
||
| # Logs | ||
| *.log* | ||
|
|
||
| # Temp directories | ||
| .temp | ||
| .tmp | ||
| .cache | ||
|
|
||
| # Yarn | ||
| **/.yarn/cache | ||
| **/.yarn/*state* | ||
|
|
||
| # Generated dirs | ||
| dist | ||
|
|
||
| # Nuxt | ||
| .nuxt | ||
| .output | ||
| .data | ||
| .vercel_build_output | ||
| .build-* | ||
| .netlify | ||
|
|
||
| # Env | ||
| .env | ||
|
|
||
| # Testing | ||
| reports | ||
| coverage | ||
| *.lcov | ||
| .nyc_output | ||
|
|
||
| # VSCode | ||
| .vscode/* | ||
| !.vscode/settings.json | ||
| !.vscode/tasks.json | ||
| !.vscode/launch.json | ||
| !.vscode/extensions.json | ||
| !.vscode/*.code-snippets | ||
|
|
||
| # Intellij idea | ||
| *.iml | ||
| .idea | ||
|
|
||
| # OSX | ||
| .DS_Store | ||
| .AppleDouble | ||
| .LSOverride | ||
| .AppleDB | ||
| .AppleDesktop | ||
| Network Trash Folder | ||
| Temporary Items | ||
| .apdisk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2024 Clerk, Inc. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| <p align="center"> | ||
| <a href="https://clerk.com?utm_source=github&utm_medium=clerk_nuxt" target="_blank" rel="noopener noreferrer"> | ||
| <picture> | ||
| <source media="(prefers-color-scheme: dark)" srcset="https://images.clerk.com/static/logo-dark-mode-400x400.png"> | ||
| <img src="https://images.clerk.com/static/logo-light-mode-400x400.png" height="64"> | ||
| </picture> | ||
| </a> | ||
| <br /> | ||
| <h1 align="center">@clerk/nuxt</h1> | ||
| </p> | ||
|
|
||
| <div align="center"> | ||
|
|
||
| [](https://clerk.com/discord) | ||
| [](https://clerk.com/docs?utm_source=github&utm_medium=clerk_nuxt) | ||
| [](https://twitter.com/intent/follow?screen_name=ClerkDev) | ||
|
|
||
| [Changelog](https://github.com/clerk/javascript/blob/main/packages/nuxt/CHANGELOG.md) | ||
| · | ||
| [Report a Bug](https://github.com/clerk/javascript/issues/new?assignees=&labels=needs-triage&projects=&template=BUG_REPORT.yml) | ||
| · | ||
| [Request a Feature](https://feedback.clerk.com/roadmap) | ||
| · | ||
| [Get help](https://clerk.com/contact/support?utm_source=github&utm_medium=clerk_nuxt) | ||
|
|
||
| </div> | ||
|
|
||
| [Clerk](https://clerk.com/?utm_source=github&utm_medium=clerk_nuxt) is the easiest way to add authentication and user management to your Vue application. Add sign up, sign in, and profile management to your application in minutes. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Nuxt 3 or later | ||
| - Node.js `>=18.17.0` or later | ||
| - An existing Clerk application. [Create your account for free](https://dashboard.clerk.com/sign-up?utm_source=github&utm_medium=clerk_nuxt). | ||
|
|
||
| ### Installation | ||
|
|
||
| Add `@clerk/nuxt` as a dependency | ||
|
|
||
| ```bash | ||
| npm install @clerk/nuxt | ||
| ``` | ||
|
|
||
| ### Build | ||
|
|
||
| To build the package locally with the TypeScript compiler, run: | ||
|
|
||
| ```bash | ||
| npm run build | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| Make sure the following environment variables are set in a `.env` file in your Nuxt project: | ||
|
|
||
| ``` | ||
| NUXT_PUBLIC_CLERK_PUBLISHABLE_KEY=[publishable-key] | ||
| CLERK_SECRET_KEY=[secret-key] | ||
| ``` | ||
|
|
||
| Then, add `@clerk/nuxt` to the `modules` section of `nuxt.config.ts`: | ||
|
|
||
| ```js | ||
| export default defineNuxtConfig({ | ||
| modules: ['@clerk/nuxt'], | ||
| }); | ||
| ``` | ||
|
|
||
| You can now start using Clerk's components. Here's a basic example showing a header component: | ||
|
|
||
| ```vue | ||
| <template> | ||
| <header> | ||
| <h1>My App</h1> | ||
| <SignedIn> | ||
| <UserButton /> | ||
| </SignedIn> | ||
| <SignedOut> | ||
| <SignInButton mode="modal" /> | ||
| </SignedOut> | ||
| </header> | ||
| </template> | ||
| ``` | ||
|
|
||
| To protect an API route, you can access the `event.context.auth` object and check the value of `userId` to determine if the user is authenticated: | ||
|
|
||
| ```ts | ||
| export default eventHandler(event => { | ||
| const { userId } = event.context.auth; | ||
|
|
||
| if (!userId) { | ||
| throw createError({ | ||
| statusCode: 401, | ||
| message: 'Unauthorized', | ||
| }); | ||
| } | ||
|
|
||
| return { userId }; | ||
| }); | ||
| ``` | ||
|
|
||
| ## Support | ||
|
|
||
| You can get in touch with us in any of the following ways: | ||
|
|
||
| - Join our official community [Discord server](https://clerk.com/discord) | ||
| - On [our support page](https://clerk.com/contact/support?utm_source=github&utm_medium=clerk_nuxt) | ||
|
|
||
| ## Contributing | ||
|
|
||
| We're open to all community contributions! If you'd like to contribute in any way, please read [our contribution guidelines](https://github.com/clerk/javascript/blob/main/docs/CONTRIBUTING.md) and [code of conduct](https://github.com/clerk/javascript/blob/main/docs/CODE_OF_CONDUCT.md). | ||
|
|
||
| ## Security | ||
|
|
||
| `@clerk/nuxt` follows good practices of security, but 100% security cannot be assured. | ||
|
|
||
| `@clerk/nuxt` is provided **"as is"** without any **warranty**. Use at your own risk. | ||
|
|
||
| _For more information and to report security issues, please refer to our [security documentation](https://github.com/clerk/javascript/blob/main/docs/SECURITY.md)._ | ||
|
|
||
| ## License | ||
|
|
||
| This project is licensed under the **MIT license**. | ||
|
|
||
| See [LICENSE](https://github.com/clerk/javascript/blob/main/packages/vue/LICENSE) for more information. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "name": "@clerk/nuxt", | ||
| "version": "0.0.0", | ||
| "description": "Clerk SDK for Nuxt", | ||
| "keywords": [ | ||
| "clerk", | ||
| "typescript", | ||
| "vue", | ||
| "nuxt", | ||
| "auth", | ||
| "authentication", | ||
| "passwordless", | ||
| "session", | ||
| "jwt" | ||
| ], | ||
| "homepage": "https://clerk.com/", | ||
| "bugs": { | ||
| "url": "https://github.com/clerk/javascript/issues" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/clerk/javascript.git", | ||
| "directory": "packages/nuxt" | ||
| }, | ||
| "license": "MIT", | ||
| "author": "Clerk", | ||
| "type": "module", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/module.d.ts", | ||
| "import": "./dist/module.js" | ||
| }, | ||
| "./server": { | ||
| "types": "./dist/runtime/server/index.d.ts", | ||
| "import": "./dist/runtime/server/index.js" | ||
| } | ||
| }, | ||
| "main": "./dist/module.js", | ||
| "types": "./dist/module.d.ts", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "tsup", | ||
|
LekoArts marked this conversation as resolved.
|
||
| "dev": "tsup --watch", | ||
| "lint": "eslint src/", | ||
| "lint:attw": "attw --pack . --ignore-rules no-resolution cjs-resolves-to-esm", | ||
| "lint:publint": "publint", | ||
| "publish:local": "pnpm dlx yalc push --replace --sig" | ||
| }, | ||
| "dependencies": { | ||
| "@clerk/backend": "1.16.4", | ||
| "@clerk/shared": "2.14.0", | ||
| "@clerk/types": "4.34.0", | ||
| "@clerk/vue": "0.0.4", | ||
| "@nuxt/kit": "^3.14.159", | ||
| "@nuxt/schema": "^3.14.159", | ||
| "h3": "^1.13.0" | ||
| }, | ||
| "devDependencies": { | ||
| "nuxt": "^3.14.159", | ||
| "typescript": "*" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18.17.0" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| declare const PACKAGE_NAME: string; | ||
| declare const PACKAGE_VERSION: string; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point I want to update our READMEs to remove this portion, let's not add it here in the first place. For the end-user who wants to use the package it's not really useful 😊