api-nextjs

next.js wrapper for tinhte-api

Usage no npm install needed!

<script type="module">
  import apiNextjs from 'https://cdn.skypack.dev/api-nextjs';
</script>

README

next.js wrapper for tinhte-api

At page components:

eg: my-project/pages/about.js

const AboutBase = () => <div>...</div>;
const About = dataHoc.NextJsPage(AboutBase);

At child components that need data:

eg: my-project/components/header/user.js

const UserBase = ({ normalizedData }) => {
  // 'normalizedData' can be used here
  return <div>...</div>;
};

const User = dataHoc.DataConsumer(UserBase, {
  const dataKey = 'user', // must be unique
  const uri = '/user/me',
  const normalize = data => ...,
});