From 0630ea51a520b1dc92ceb391138f93d01d032771 Mon Sep 17 00:00:00 2001 From: pilcrow Date: Sat, 22 Jun 2024 15:09:33 +0900 Subject: [PATCH] Docs: Update examples (#1610) --- docs/pages/getting-started/astro.md | 2 +- docs/pages/getting-started/express.md | 61 ------------------- docs/pages/getting-started/index.md | 4 +- docs/pages/getting-started/nextjs-app.md | 2 +- docs/pages/getting-started/nextjs-pages.md | 2 +- docs/pages/getting-started/nuxt.md | 2 +- docs/pages/getting-started/solidstart.md | 2 +- docs/pages/getting-started/sveltekit.md | 2 +- docs/pages/tutorials/github-oauth/index.md | 2 + docs/pages/tutorials/index.md | 4 ++ .../tutorials/username-and-password/index.md | 2 + 11 files changed, 17 insertions(+), 68 deletions(-) delete mode 100644 docs/pages/getting-started/express.md diff --git a/docs/pages/getting-started/astro.md b/docs/pages/getting-started/astro.md index 8ee2bb116..81e378528 100644 --- a/docs/pages/getting-started/astro.md +++ b/docs/pages/getting-started/astro.md @@ -109,6 +109,6 @@ declare namespace App { You can learn all the concepts and APIs by reading the [Basics section](/basics/sessions) in the docs. If you prefer writing code immediately, check out the [Tutorials](/tutorials) page or the [examples repository](https://github.com/lucia-auth/examples/tree/main). -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. +This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. If you have any questions, [join our Discord server](https://discord.com/invite/PwrK3kpVR3)! diff --git a/docs/pages/getting-started/express.md b/docs/pages/getting-started/express.md deleted file mode 100644 index 220f021c9..000000000 --- a/docs/pages/getting-started/express.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: "Getting started in Express" ---- - -# Getting started in Express - -## Installation - -Install Lucia using your package manager of your choice. - -``` -npm install lucia -``` - -## Initialize Lucia - -Import `Lucia` and initialize it with your adapter. Refer to the [Database](/database) page to learn how to set up your database and initialize the adapter. Make sure you configure the `sessionCookie` option and register your `Lucia` instance type. - -```ts -import { Lucia } from "lucia"; - -const adapter = new BetterSQLite3Adapter(db); // your adapter - -export const lucia = new Lucia(adapter, { - sessionCookie: { - attributes: { - // set to `true` when using HTTPS - secure: process.env.NODE_ENV === "production" - } - } -}); - -// IMPORTANT! -declare module "lucia" { - interface Register { - Lucia: typeof lucia; - } -} -``` - -## Polyfill - -If you're using Node.js 18 or below, you'll need to polyfill the Web Crypto API. This is not required in Node.js 20, CloudFlare Workers, Deno, Bun, and Vercel Edge Functions. This can be done either by importing `webcrypto`, or by enabling an experimental flag. - -```ts -import { webcrypto } from "node:crypto"; - -globalThis.crypto = webcrypto as Crypto; -``` - -``` -node --experimental-web-crypto index.js -``` - -## Next steps - -You can learn all the concepts and APIs by reading the [Basics section](/basics/sessions) in the docs. If you prefer writing code immediately, check out the [Tutorials](/tutorials) page or the [examples repository](https://github.com/lucia-auth/examples/tree/main). - -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. - -If you have any questions, [join our Discord server](https://discord.com/invite/PwrK3kpVR3)! diff --git a/docs/pages/getting-started/index.md b/docs/pages/getting-started/index.md index a987877be..c427a3955 100644 --- a/docs/pages/getting-started/index.md +++ b/docs/pages/getting-started/index.md @@ -14,6 +14,8 @@ A framework-specific guide is also available for: - [SolidStart](/getting-started/solidstart) - [SvelteKit](/getting-started/sveltekit) +Example projects for Astro, Express, Hono, Next.js App Router, Next.js Pages Router, Nuxt, and SvelteKit are available in the [example repository](https://github.com/lucia-auth/examples). + ## Installation Install Lucia using your package manager of your choice. @@ -64,4 +66,4 @@ node --experimental-web-crypto index.js ## The Copenhagen Book -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. +This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. diff --git a/docs/pages/getting-started/nextjs-app.md b/docs/pages/getting-started/nextjs-app.md index fa307ee2d..83827d87b 100644 --- a/docs/pages/getting-started/nextjs-app.md +++ b/docs/pages/getting-started/nextjs-app.md @@ -60,6 +60,6 @@ node --experimental-web-crypto index.js You can learn all the concepts and APIs by reading the [Basics section](/basics/sessions) in the docs. If you prefer writing code immediately, check out the [Tutorials](/tutorials) page or the [examples repository](https://github.com/lucia-auth/examples/tree/main). -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. +This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. If you have any questions, [join our Discord server](https://discord.com/invite/PwrK3kpVR3)! diff --git a/docs/pages/getting-started/nextjs-pages.md b/docs/pages/getting-started/nextjs-pages.md index 83bc1e0dc..a191db00c 100644 --- a/docs/pages/getting-started/nextjs-pages.md +++ b/docs/pages/getting-started/nextjs-pages.md @@ -82,6 +82,6 @@ export async function middleware(request: NextRequest): Promise { You can learn all the concepts and APIs by reading the [Basics section](/basics/sessions) in the docs. If you prefer writing code immediately, check out the [Tutorials](/tutorials) page or the [examples repository](https://github.com/lucia-auth/examples/tree/main). -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. +This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. If you have any questions, [join our Discord server](https://discord.com/invite/PwrK3kpVR3)! diff --git a/docs/pages/getting-started/nuxt.md b/docs/pages/getting-started/nuxt.md index d61443865..e1b9728d9 100644 --- a/docs/pages/getting-started/nuxt.md +++ b/docs/pages/getting-started/nuxt.md @@ -112,6 +112,6 @@ declare module "h3" { You can learn all the concepts and APIs by reading the [Basics section](/basics/sessions) in the docs. If you prefer writing code immediately, check out the [Tutorials](/tutorials) page or the [examples repository](https://github.com/lucia-auth/examples/tree/main). -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. +This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. If you have any questions, [join our Discord server](https://discord.com/invite/PwrK3kpVR3)! diff --git a/docs/pages/getting-started/solidstart.md b/docs/pages/getting-started/solidstart.md index be86d266f..c479e27cf 100644 --- a/docs/pages/getting-started/solidstart.md +++ b/docs/pages/getting-started/solidstart.md @@ -105,6 +105,6 @@ export default defineConfig({ You can learn all the concepts and APIs by reading the [Basics section](/basics/sessions) in the docs. If you prefer writing code immediately, check out the [Tutorials](/tutorials) page or the [examples repository](https://github.com/lucia-auth/examples/tree/main). -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. +This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. If you have any questions, [join our Discord server](https://discord.com/invite/PwrK3kpVR3)! diff --git a/docs/pages/getting-started/sveltekit.md b/docs/pages/getting-started/sveltekit.md index 519f3f1fb..c29ff4d60 100644 --- a/docs/pages/getting-started/sveltekit.md +++ b/docs/pages/getting-started/sveltekit.md @@ -101,6 +101,6 @@ export {}; You can learn all the concepts and APIs by reading the [Basics section](/basics/sessions) in the docs. If you prefer writing code immediately, check out the [Tutorials](/tutorials) page or the [examples repository](https://github.com/lucia-auth/examples/tree/main). -This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com/mfa). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. +This documentation often references [the Copenhagen Book](https://thecopenhagenbook.com). This is an open-source guide on implementing auth and should come in handy when implementing anything auth, including passkeys, multi-factor authentication, and a bit of cryptography. We recommend reading it to learn more about auth in web applications. If you have any questions, [join our Discord server](https://discord.com/invite/PwrK3kpVR3)! diff --git a/docs/pages/tutorials/github-oauth/index.md b/docs/pages/tutorials/github-oauth/index.md index 5d51b6b01..520f1fb44 100644 --- a/docs/pages/tutorials/github-oauth/index.md +++ b/docs/pages/tutorials/github-oauth/index.md @@ -11,3 +11,5 @@ The tutorials go over how to implement a basic GitHub OAuth and cover the basics - [Next.js Pages router](/tutorials/github-oauth/nextjs-pages) - [Nuxt](/tutorials/github-oauth/nuxt) - [SvelteKit](/tutorials/github-oauth/sveltekit) + +Example projects for [Express](https://github.com/lucia-auth/examples/tree/main/express/github-oauth) and [Hono](https://github.com/lucia-auth/examples/tree/main/hono/github-oauth) are also available. diff --git a/docs/pages/tutorials/index.md b/docs/pages/tutorials/index.md index 778070722..570019733 100644 --- a/docs/pages/tutorials/index.md +++ b/docs/pages/tutorials/index.md @@ -16,6 +16,8 @@ Learn to set up GitHub OAuth, handle authentication, and manage user sessions. - [Nuxt](/tutorials/github-oauth/nuxt) - [SvelteKit](/tutorials/github-oauth/sveltekit) +Example projects for [Express](https://github.com/lucia-auth/examples/tree/main/express/github-oauth) and [Hono](https://github.com/lucia-auth/examples/tree/main/hono/github-oauth) are also available. + ## Username and Password Understand how to implement a secure username and password authentication system. @@ -25,3 +27,5 @@ Understand how to implement a secure username and password authentication system - [Next.js Pages router](/tutorials/username-and-password/nextjs-pages) - [Nuxt](/tutorials/username-and-password/nuxt) - [SvelteKit](/tutorials/username-and-password/sveltekit) + +Example projects for [Express](https://github.com/lucia-auth/examples/tree/main/express/username-and-password) and [Hono](https://github.com/lucia-auth/examples/tree/main/hono/username-and-password) are also available. diff --git a/docs/pages/tutorials/username-and-password/index.md b/docs/pages/tutorials/username-and-password/index.md index accf0712d..b136b26bb 100644 --- a/docs/pages/tutorials/username-and-password/index.md +++ b/docs/pages/tutorials/username-and-password/index.md @@ -11,3 +11,5 @@ The tutorials go over how to implement a basic username and password auth and co - [Next.js Pages router](/tutorials/username-and-password/nextjs-pages) - [Nuxt](/tutorials/username-and-password/nuxt) - [SvelteKit](/tutorials/username-and-password/sveltekit) + +Example projects for [Express](https://github.com/lucia-auth/examples/tree/main/express/username-and-password) and [Hono](https://github.com/lucia-auth/examples/tree/main/hono/username-and-password) are also available.