https://github.com/gragland/divjoy-next-vercel
A React starter powered by Next.js, Firebase, Bulma, and Vercel 👌
https://github.com/gragland/divjoy-next-vercel
boilerplate bulma firebase firestore nextjs react template vercel
Last synced: 5 months ago
JSON representation
A React starter powered by Next.js, Firebase, Bulma, and Vercel 👌
- Host: GitHub
- URL: https://github.com/gragland/divjoy-next-vercel
- Owner: gragland
- Created: 2019-10-20T16:35:44.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T17:52:24.000Z (over 2 years ago)
- Last Synced: 2024-05-01T15:49:41.241Z (12 months ago)
- Topics: boilerplate, bulma, firebase, firestore, nextjs, react, template, vercel
- Language: JavaScript
- Homepage:
- Size: 870 KB
- Stars: 54
- Watchers: 3
- Forks: 11
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### This is an example codebase created with [Divjoy](https://divjoy.com/?utm_campaign=github-divjoy-next-vercel&utm_source=github&utm_medium=website&utm_content=brand) ✨
⚠️ You must [purchase a license](https://divjoy.com/?utm_campaign=github-divjoy-next-vercel&utm_source=github&utm_medium=website&utm_content=purchase) to use this code
⚠️ The code in this repo is not up-to-date. Head over to [Divjoy](https://divjoy.com/?utm_campaign=github-divjoy-next-vercel&utm_source=github&utm_medium=website&utm_content=purchase) to generate a new Next.js + Vercel project.
## 👉 Get Started
Install dependencies
```
npm install
```Update your `.env` file with values for each environment variable
```
API_KEY=AIzaSyBkkFF0XhNZeWuDmOfEhsgdfX1VBG7WTas
etc ...
```Run the development server
```
npm run dev
```When the above command completes you'll be able to view your website at `http://localhost:3000`
## 🥞 Stack
This project uses the following libraries and services:
- Framework - [Next.js](https://nextjs.org)
- UI Kit - [Bulma](https://bulma.io)
- Authentication - [Firebase Auth](https://firebase.google.com/products/auth)
- Database - [Cloud Firestore](https://firebase.google.com/products/firestore)
- Newsletter - [Mailchimp](https://mailchimp.com)
- Contact Form - [Formspree](https://formspree.io)
- Analytics - [Google Analytics](https://googleanalytics.com)
- Hosting - [Vercel](https://vercel.com)## 📚 Guide
Styles
You can edit Bulma SASS variables in the global stylesheet located atsrc/styles/global.scss
. Variables allow you to control global styles (like colors and fonts), as well as element specific styles (like button padding). Before overriding Bulma elements with custom style check the Bulma docs to see if you can do what need by tweaking a SASS variable.
Custom styles are located in their related component's directory. For example, if any custom style is applied to the Navbar component you'll find it insrc/components/Navbar.scss
. We ensure custom styles are scoped to their component by prepending the classname with the component name (such as.Navbar__brand
). This ensures styles never affect elements in other components. If styles need to be re-used in multiple components consider creating a new component that encapsulates that style and structure and using that component in multiple places.
Routing
This project uses the built-in Next.js router and its convenientuseRouter
hook. Learn more in the Next.js docs.
```jsx
import Link from 'next/link';
import { useRouter } from 'next/router';function MyComponent(){
// Get the router object
const router = useRouter();// Get value from query string (?postId=123) or route param (/:postId)
console.log(router.query.postId);// Get current pathname
console.log(router.pathname)// Navigate with the component or with router.push()
return (
);
}
```
Authentication
This project uses Firebase Auth and includes a convenientuseAuth
hook (located insrc/util/auth.js
) that wraps Firebase and gives you common authentication methods. Depending on your needs you may want to edit this file and expose more Firebase functionality.```js
import { useAuth } from './../util/auth.js';function MyComponent(){
// Get the auth object in any component
const auth = useAuth();// Depending on auth state show signin or signout button
// auth.user will either be an object, null when loading, or false if signed out
return (
);
}
```
Database
This project uses Cloud Firestore and includes some data fetching hooks to get you started (located insrc/util/db.js
). You'll want to edit that file and add any additional query hooks you need for your project.```js
import { useAuth } from './../util/auth.js';
import { useUser } from './../util/db.js';function MyComponent(){
const auth = useAuth();// Fetch extra user info from database
// It's okay if uid is undefined while auth is still loading
// The hook will return a "loading" status until it has a uid to fetch data
const uid = auth.user ? auth.user.uid : undefined;
const { data: user, status } = useUser(uid);// Once we have the user data then display their name
return (
{status === "loading" ? (
One moment please
) : (
Hello {user.name}
)}
);
}
```
Deployment
Install the Vercel CLI```
npm install -g vercel
```Add each variable from `.env` to your Vercel project with the following command. You'll be prompted to enter its value and then choose one or more environments (development, preview, or production).
Learn more here.```
vercel env add VARIABLE_NAME
```Run this command to deploy a preview (for testing a live deployment)
```
vercel
```Run this command to deploy to production
```
vercel --prod
```See the Vercel docs for more details.
Other
The Next.js documentation covers many other topics.
This project was initially created using Divjoy, a React codebase generator. Feel free to ask questions in the Divjoy forum and we'll do our best to help you out.