A Next.js blog with a dashboard and a text editor.
A Next.Js blog with a password-protected dashboard where a blog owner can either upload an .md file, or write in the editor to create a new post. When a post is added or removed from the dashboard, an on-demand revalidation is triggered. The authentication is handled by next-auth.
Here's a live demo, password is already added so you can play around with it.
-
Clone repo.
- optionally configure your local instance:
git remote add instance <instance_url>
- stage and commit local changes.
git push -u instance <branchName>
(push to remote instance only).git pull origin master
(pull changes from template).
- optionally configure your local instance:
-
npm install
packages. -
Set up the database to store your posts (we're using mongodb for this demo).
-
Create .env.local file with these variables:
-
(mind that fields marked as "value_1" and "value_2" must match):
MONGODB_URI=value
MONGODB_DB=value
MONGODB_COLLECTION=valueNEXT_PUBLIC_SAVE_TOKEN=value_1
SAVE_TOKEN=value_1UPLOAD_PASSWORD=value_2
LOGIN_PASSWORD=value_2
NEXTAUTH_SECRET=value_2
REVALIDATE_TOKEN=value
USER_TOKEN=valueNEXT_PUBLIC_BASE_URL=http://localhost:3000/api
NEXTAUTH_URL=http://localhost:3000
BASE_URL=http://localhost:3000
NEXT_PUBLIC_URL=http://localhost:3000
-
-
Open /lib/data.js, change values for your own.
-
npm run dev
to run locally in dev mode, ornpm run build
andnpm start
to run production build locally.