A full-stack application with authentication, SSR and SQLite, running on the edge with Nuxt 3.
A demonstration using Nuxt with server-side rendering on the edge, authentication and database querying using SQLite in production.
https://github.com/Atinux/nuxt-todos-edge/assets/904724/5f3bee55-dbae-4329-8057-7d0e16e92f81
Make sure to install the dependencies using pnpm:
pnpm i
Create a GitHub Oauth Application with:
http://localhost:3000http://localhost:3000/api/auth/githubAdd the variables in the .env file:
NUXT_OAUTH_GITHUB_CLIENT_ID="my-github-oauth-app-id"
NUXT_OAUTH_GITHUB_CLIENT_SECRET="my-github-oauth-app-secret"
To create sealed sessions, you also need to add NUXT_SESSION_SECRET in the .env with at least 32 characters:
NUXT_SESSION_SECRET=your-super-long-secret-for-session-encryption
Start the development server on http://localhost:3000
npm run dev
Create a CF pages deployment linked to your GitHub repository. Make sure to select Version 2 (Beta) as the build system version.
NUXT_OAUTH_GITHUB_CLIENT_ID=...
NUXT_OAUTH_GITHUB_CLIENT_SECRET=...
NUXT_SESSION_PASSWORD=...
Set the build command to:
npm run build
And the output directory to dist/
Lastly, in the project settings -> Functions, add the binding between your D1 database and the DB variable:

Copy the contents from server/db/migrations/0000_sloppy_starfox.sql into the D1 console to seed the database.
You can also use Turso database instead of CloudFlare D1 by creating a database and adding the following env variables:
TURSO_DB_URL=...
TURSO_DB_TOKEN=...
You can see a live demo using Turso on https://nuxt-todos-turso.pages.dev