packages/next/client/amp-dev.js
async function tryApplyUpdates () {
  if (!isUpdateAvailable() || !canApplyUpdates()) {
    return
  }
  try {
    const res = await fetch(`${hotUpdatePath}${curHash}.hot-update.json`)
    const data = await res.json()
    const curPage = page === '/' ? 'index' : page
    const pageUpdated = Object.keys(data.c)
      .some(mod => {
        return (
          mod.indexOf(`pages${curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`}`) !== -1 ||
          mod.indexOf(`pages${curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`}`.replace(/\//g, '\\')) !== -1
        )
      })

    if (pageUpdated) {
      document.location.reload(true)
    } else {
      curHash = mostRecentHash
    }
  } catch (err) {
    console.error('Error occurred checking for update', err)
    document.location.reload(true)
  }
}
async function tryApplyUpdates () {
  if (!isUpdateAvailable() || !canApplyUpdates()) {
    return
  }
  try {
    const res = await fetch(`${hotUpdatePath}${curHash}.hot-update.json`)
    const data = await res.json()
    const curPage = page === '/' ? 'index' : page
    const pageUpdated = Object.keys(data.c)
      .some(mod => {
        return (
          mod.indexOf(`pages${curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`}`) !== -1 ||
          mod.indexOf(`pages${curPage.substr(0, 1) === '/' ? curPage : `/${curPage}`}`.replace(/\//g, '\\')) !== -1
        )
      })

    if (pageUpdated) {
      document.location.reload(true)
    } else {
      curHash = mostRecentHash
    }
  } catch (err) {
    console.error('Error occurred checking for update', err)
    document.location.reload(true)
  }
}
This function reads code updates on the fly and hard reloads the page when it has changed.