Thepurposeofthisstarterkitisnottobecompletesolution,butintroductionforcreatinghighperformancewebsiteswithNext.js,ReactandGraphQL.WeusethisrepositoryfornewprojectsatAtherosIntelligenceandastherepositoryforourarticlesatGraphQLMastery
Clonetherepositorywithgitclonegit@github.com:atherosai/next-react-graphql-apollo-hooks.gitTopreservesecuredependenciesinpackage-lock.jsonusenpmcitoinstallpackagesNode.jsversionEventhoughthatthestarterkitshouldworkwitholderNodeversions,IwouldsuggesttouselatestNodeLTSversion.Inpackage.json.Wehavesetrequirementsasfollows:
"engines":{"node":">=10.0.0","npm":">6"},Technologies&mainfeaturesNext.jsReactGraphQL(Apolloserver)ApolloclientReactApolloHooksNode.jsTypeScriptGraphQLCodeGeneratorJestProductionusageInordertoachievethebestperformanceyoushouldhaveenabledhttp/2andalsoenablecompressioninyourreverseproxy(nginx).UptodateNode.jsserverisalsoverybenefitial.
EnvironmentconfigurationThesolutionforenvironmentvariablesisbuiltusingdotenvlibraryandtwoenvironmentvariables.WellknownNODE_ENVvariablecanbesetasdevelopmentorproductionandourCUSTOM_ENV,whichdefinestheenvironment.Thiscanbeyourstaging,production,localenvironmentorevenyourbuildserver.Thesetwovariablesdefinethenameof.envfilein/secretsfolderthatwillbeused.Ifwewouldliketoforexampledefinetheconfigforourstagingenvironmentwewouldcreatethefilecalled/secrets/production-staging.envandplacealltheenvironmentvariablesthere.Theexampleforsuchafilecanbeforexamplethefollowingthatwecanusefordevelopment
NODE_ENV=developmentCUSTOM_ENV=localPORT=3000API_URL=https://localhost:3000/graphqlHOST=https://localhost:3000SecurityandauditYoucanrunsecurityauditondependencieswith.Besurethatyouusepackage-lock.jsoninourrepository.
npmaudit
评论