This project is meant to provide the base layer to kickstart a new frontend project at Open Collective. The goal is to provide a solid foundation to build upon, while making sure we can bring back the code to the main Open Collective codebase whenever we need.
- Next.js for server-side rendering and routing
- Styled Components for styling, with our custom design system plugged in
- Apollo for GraphQL queries
- ESLint for linting, with our custom config & Prettier
- Renovate for automated dependency updates
- A minimal Github Actions CI config
- A Vercel configuration for deployment and preview
To do:
- Jest for testing
- Depcheck
- Import frontend's fonts
- Husky pre-commit lint hook
- Replace all
<Link><a>
with our custom link component from frontend - Invalidate OAuth tokens on logout
Click on "Use this template" above (or alternatively, fork the repository) then clone it:
git clone https://github.com/opencollective/opencollective-frontend-template.git
cd opencollective-frontend-template
npm install
By default, the app will try to connect to the Open Collective staging API & frontend.
To run the template against your local frontend/api:
- Create a new OAuth app
- Run
cp .env.local.example .env.local
- Edit
.env.local
and setOPENCOLLECTIVE_OAUTH_APP_ID
andOPENCOLLECTIVE_OAUTH_APP_SECRET
to your OAuth app credentials
Learn more about the environment variables in NextJS: https://nextjs.org/docs/basic-features/environment-variables.
To run your site locally (default: http://localhost:3004), use:
npm run dev
To run it in production mode, use:
npm run build
npm run start
- To update GraphQL schemas after an API change, run
npm run graphql:update
.
- Create a new project on Vercel, pick your forked repository.
- On the "Configure Project" step, keep the default settings (NextJS), set the required Environment variables and click "Deploy":
NEXTAUTH_SECRET
: a random string used to encrypt JWTsOPENCOLLECTIVE_OAUTH_APP_ID
: the ID of the OAuth app you created on the APIOPENCOLLECTIVE_OAUTH_APP_SECRET
: the secret of the OAuth app you created on the APINEXT_PUBLIC_OPENCOLLECTIVE_OAUTH_SCOPES
: a comma separated list of OAuth scopes you want to request from the API (e.g.account,transactions
)