Context
This boilerplate has been built based on a real professional use-case.
This use case relies on the following built-in 3rd parties:
- Monitoring (Sentry 3rd party, large freemium)
- Analytics (Amplitude 3rd party, large freemium)
- GraphQL API (GraphCMS 3rd party, small freemium)
- I18n (Locize 3rd party, 2w free trial, not free)
- Hosting (Zeit 3rd party, large freemium, no pay-or-leave)
Also, it features the following built-in design choices:
- SSR (no SSG nor static optimization are possible without altering the boilerplate in a non-straightforward way)
- Multi-tenants/monorepo (not single-tenant friendly without altering the boilerplate in a non-straightforward way)
Legend:
Freemium means free with "more or less" limited capabilities on free plan.
- Small means the free plan is considered too limited for most real use cases
- Large means the free plan is limited but large enough to cover non enterprise-grade needs
Concerns
There are 2 main concerns at hand.
It's too complicated/opinionated
Opinions can be good, I personally don't regret those 3rd party choices. But not everyone like them, not everyone need them either. They are currently built-in, but it would be better to have them opt-in and let people easily choose what boilerplate preset fits their need the most closely.
It's not free
Locize provides a free trial, but it's just a trial and it's not free. Thus, it's a strong issue for associations and organisation that don't have any funds, or can't afford it.
GraphCMS free plan is limited to 500 records, which can be considered "good enough" or "far too little" depending on the use cases.
Needs
- Quickly understanding which boilerplate to use based on my current requirements
- Quickly clone the boilerplate I want to use (git clone specific branch)
- Quickly see what changes have been applied to add/remove a feature compared to another preset
- Ability to apply identical updates to multiple presets easily (ease to maintain all those presets by reducing issues when applying changes that are common to all, such as dependency updates, security updates, good practices, etc.)
Solution
I believe the best way to keep the current advanced/opinionated boilerplate while allowing for simpler/faster re-use is to create "presets" from the initial boilerplate. A preset could be considered as similar to a fork, but lives within the same repository.
After much thinking on the matter, I've come to the following requirements:
- A preset should live within a git branch.
- Each of those branch will have its own "preset origin" from where it got "forked".
- Those branch must not be confused with working branches, it must be obvious they are official, stable presets where anyone can get started from.
- Each preset should specify whether it is using SSR or SSG design
- Each preset should specify whether it is using multi-tenants or single-tenant design
- Each preset should specify which 3rd parties or features have been removed (compared to the most complex preset, which currently lives in the
master
branch)
- This boilerplate will likely evolve in the future, maybe more features or 3rd parties will be added/removed/changed. It should be made easy to create major versions of the presets, based on a different base major preset.
- Each preset must be documented in the main README.md file, and explained thoroughly. A link to the branch and to the PR must be present (against its "preset origin" so that only minimal changes are shown in the diff), also a
git clone
command must be present to allow for quick local clone of a preset
- A PR can be created (but closed to avoid false-positive PR) for quick review of source code changes between two presets. It will also allow the community to post comment on the PR source code changes if questions arise and will reduce the github issues created if proper answers are given to those questions, as future readers may also ask themselves the same question and see a proper answer right there.
- A preset cannot contain uppercased letters, as Zeit won't allow to create a project with uppercases as per now@17 CLI version
Which led to the following specification:
- Branch naming, each official preset's branch must (in order):
- Start with
v
(for "version", as Next.js and Zeit may evolve in the future, and require to provide different presets (old ones and new ones) while keeping the same features and vendors)
- Then with the major version of the preset (i.e:
1
)
- Then with a
ssr
/ssg
tag
- Then with a
mst
tag (if multiple single-tenants design), or mt
tag if multi-tenant (single-tenancy isn't something we aim to support, because MST is better (ROI), in our opinion)
- Then, with a shortened list of all features/vendor differences with the "origin preset" (we can't list them all due to domain name characters limit (53 max))
- Zeit project naming, each official preset's
now.json
file must (in order) :
- Start with
nrn-
- Then with the branch name
- Additionally, for
mst
branches, they will also specify "customer1" or customer2" at the end of the name
Examples:
Most complete example, with all 3rd parties, SSR and monorepo design
(basically what's currently in the master branch)
Branch name: v1-ssr-mst-aptd-gcms-lcz-sty
Zeit project's names: nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c1
, nrn-v1-ssr-mst-aptd-gcms-lcz-sty-c2
(in now.*.json files, as name
)
Example without monorepo design (single-tenant instead)
Branch name: v1-ssr-mt-aptd-gcms-lcz-sty
Zeit project's names: nrn-v1-ssr-mt-aptd-gcms-lcz-sty
From: v1-ssr-mst-aptd-gcms-lcz-sty
branch
Example without Locize 3rd party
Branch name: v1-ssr-mst-aptd-gcms-sty
Zeit project's names: v1-ssr-mst-aptd-gcms-sty
From: v1-ssr-mst-aptd-gcms-lcz-sty
branch
Example without i18n nor monorepo
Branch name: v1-ssr-mt-aptd-gcms-sty
Zeit project's names: nrn-v1-ssr-mt-aptd-gcms-sty
From: v1-ssr-mt-aptd-gcms-lcz-sty
branch (because it's the closest of what we need)
Needs checkup
Feedback
Please share your questions, concerns or suggestion.