pages/
app/
Illustrations from:
https://www.flavienbonvin.com/data-building-strategy-for-nextjs-app/
const Page = ({ data }) => {
// Render data...
}
// This gets called on every request
export async function getServerSideProps({id}) {
// Fetch data from external API
const res = await fetch(`https://.../${id}`)
const data = await res.json()
// Pass data to the page via props
return { props: { data } }
}
export default Page
// This function gets called at build time
export async function getStaticPaths() {
const res = await fetch('https://.../posts')
const posts = await res.json()
// Get the paths we want to pre-render based on posts
const paths = posts.map((post) => ({
params: { slug: post.slug },
}))
return { paths, fallback: false }
}
export async function getStaticProps() {
const res = await fetch(‘https://.../posts’)
const posts = await res.json()
return {
props: {
posts,
},
// Next.js will attempt to regenerate the page:
// - When a request comes in
// - At most once every 10 seconds
revalidate: 10, // In seconds
}
}
// app/page.tsx
async function getData() {
const res = await fetch('https://api.example.com/...');
// The return value is *not* serialized
// You can return Date, Map, Set, etc.
// Recommendation: handle errors
if (!res.ok) {
// This will activate the closest `error.js` Error Boundary
throw new Error('Failed to fetch data');
}
return res.json();
}
export default async function Page() {
const data = await getData();
if(!data) { notFound() }
return <main></main>;
}
Coordinate projects is hard, "leke alene, sammen" makes it easier!
Plan to share functions and APIs and maybe more later. The monorepo will hopefully make refactoring and maintenance easier.
Experience with Lerna (Tarjes private monorepo, "Muna")
Why we choose Turborepo...
because Tarje already decided...
turbo|npm run dev
Not the most comprehensive tool,
but just what we need and plays nice with Vercel. And we can change to another monorepo build tool if necessary.
Link shortener
Docs
API
CHC-*
SPS-*
New Marcus frontend
Exhibitions
Termportalen
Ordbøkene
Shared Apps
ESLint
TSConfig
Tailwind-ui
Utils
Packages
Shared
Shared API
Shared design systems
Add shared analytics? Ordbøkene?
DU have reorganized and have focus groups for fullstack stuff and architecture. Hopefully we will strengthen collaboration, control and planning.
Lets have a look at the repo!
Web app
Serverless API endpoints
NREC
FUSEKI
NREC
KIBANA
ES
SANITY
token
token
(at build time)
Frontend
Api
ITA
Postgres
NREC
API
XATA
token
About 250$ worth of AWS/Cloudflare resources for free
More the more complicated limitations: https://vercel.com/docs/concepts/limits/overview
Fun topic, guess someone already brought it up...
UB have started the process on creating the necessary documents explaining our choices...
For now, we have no user information.
Vercel will not be the place for all apps created by DU, partly dictated by Shrems II.