Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geovanisouza92/nextjs-with-polyfill-library
https://github.com/geovanisouza92/nextjs-with-polyfill-library
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/geovanisouza92/nextjs-with-polyfill-library
- Owner: geovanisouza92
- Created: 2022-01-31T13:42:51.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-31T13:50:11.000Z (almost 3 years ago)
- Last Synced: 2023-03-22T20:53:36.150Z (almost 2 years ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Next.js with [polyfill-library](https://github.com/financial-times/polyfill-library)
1. Install the polyfill-library: `npm install --save polyfill-library`
2. Create a polyfill [API route](https://nextjs.org/docs/api-routes/api-middlewares):
```js
// pages/api/polyfills.js
import polyfillLib from 'polyfill-library'export default async function handler(req, res) {
const polyfill = await polyfillLib.getPolyfillString({
uaString: req.headers['user-agent'],
})
res.setHeader('Vary', 'User-Agent')
res.setHeader('Cache-Control', 'public, max-age=31536000')
res.write(polyfill)
res.end()
}
```3. Deploy 😎 🚀