Skip to content
Merged
Show file tree
Hide file tree
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 Nov 12, 2024
390eadf
chore(nuxt): Update imports
wobsoriano Nov 12, 2024
270e467
chore(nuxt): Add more comments
wobsoriano Nov 12, 2024
a61ee47
fix(vue,nuxt): type exports
wobsoriano Nov 12, 2024
7cfe2e6
chore: add changeset
wobsoriano Nov 12, 2024
4001ffe
chore(nuxt): Add @clerk/types to dev deps
wobsoriano Nov 12, 2024
9d63caa
chore(nuxt): Add more helpful comments
wobsoriano Nov 13, 2024
04dfc6a
chore(nuxt): Rename main entrypoint for more clarity
wobsoriano Nov 13, 2024
83f5ea2
chore(nuxt): Add comment about bundling
wobsoriano Nov 13, 2024
a04966a
chore(nuxt,vue): Add dev script
wobsoriano Nov 13, 2024
83bc234
chore(nuxt,vue): Directly import error thrower from utils
wobsoriano Nov 13, 2024
480bcca
chore(nuxt): Add Nuxt v4 support
wobsoriano Nov 13, 2024
8ff765c
chore(nuxt): Revert version
wobsoriano Nov 13, 2024
487827e
chore(nuxt): Add README and LICENSE
wobsoriano Nov 13, 2024
bd75cba
chore(nuxt): Update README
wobsoriano Nov 13, 2024
384b5d2
chore(nuxt): Update README
wobsoriano Nov 13, 2024
545ab28
chore(nuxt): Use global variables for module name and version
wobsoriano Nov 14, 2024
9c9723f
chore(nuxt): Fix dependencies
wobsoriano Nov 14, 2024
d600929
chore: Reinstall deps with pnpm
wobsoriano Nov 14, 2024
763eefa
chore(nuxt): Replace npx command with pnpm dlx
wobsoriano Nov 14, 2024
313a20b
chore(nuxt): Fix vue version and remove unused export
wobsoriano Nov 14, 2024
efd300e
chore(nuxt): Fix missing dependencies required by pnpm
wobsoriano Nov 14, 2024
7f4d72b
chore: simplify tsconfig
wobsoriano Nov 14, 2024
ec8284f
Update packages/nuxt/README.md
wobsoriano Nov 15, 2024
86262db
chore(nuxt): Remove unused dep
wobsoriano Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/cuddly-tools-live.md
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)
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
run: |
if [ "${{ matrix.node-version }}" == "18" ]; then
echo "Running tests on Node 18 only for packages with LTS support."
pnpm turbo test $TURBO_ARGS --filter="@clerk/astro" --filter="@clerk/backend" --filter="@clerk/express" --filter="@clerk/nextjs" --filter="@clerk/clerk-react" --filter="@clerk/clerk-sdk-node" --filter="@clerk/shared" --filter="@clerk/remix" --filter="@clerk/tanstack-start" --filter="@clerk/elements" --filter="@clerk/vue"
pnpm turbo test $TURBO_ARGS --filter="@clerk/astro" --filter="@clerk/backend" --filter="@clerk/express" --filter="@clerk/nextjs" --filter="@clerk/clerk-react" --filter="@clerk/clerk-sdk-node" --filter="@clerk/shared" --filter="@clerk/remix" --filter="@clerk/tanstack-start" --filter="@clerk/elements" --filter="@clerk/vue" --filter="@clerk/nuxt"
else
echo "Running tests for all packages on Node 20."
pnpm turbo test $TURBO_ARGS
Expand Down
4 changes: 4 additions & 0 deletions packages/nuxt/.eslintrc.cjs
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'],
};
56 changes: 56 additions & 0 deletions packages/nuxt/.gitignore
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
21 changes: 21 additions & 0 deletions packages/nuxt/LICENSE
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.
125 changes: 125 additions & 0 deletions packages/nuxt/README.md
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">

[![Chat on Discord](https://img.shields.io/discord/856971667393609759.svg?logo=discord)](https://clerk.com/discord)
[![Clerk documentation](https://img.shields.io/badge/documentation-clerk-green.svg)](https://clerk.com/docs?utm_source=github&utm_medium=clerk_nuxt)
[![Follow on Twitter](https://img.shields.io/twitter/follow/ClerkDev?style=social)](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
```
Comment on lines +44 to +50

Copy link
Copy Markdown
Contributor

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 😊


## 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.
70 changes: 70 additions & 0 deletions packages/nuxt/package.json
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",
Comment thread
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"
}
}
2 changes: 2 additions & 0 deletions packages/nuxt/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const PACKAGE_NAME: string;
declare const PACKAGE_VERSION: string;
Loading