rsnext/examples/script-component/README.md

34 lines
1.5 KiB
Markdown
Raw Normal View History

# Script component
This example shows different strategies that can be used for the [`next/script` component](https://nextjs.org/docs/basic-features/script):
- [Loading Polyfills](./pages/polyfill.tsx)
- [Lazy loading](./pages/lazy.tsx)
- [Executing code after loading](./pages/onload.tsx)
- [Inline scripts](./pages/inline.tsx)
- [Forwarding attributes](./pages/attributes.tsx)
## Deploy your own
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/script-component)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/script-component&project-name=script-component&repository-name=script-component)
## How to use
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
```bash
npx create-next-app --example script-component script-component-app
```
```bash
yarn create next-app --example script-component script-component-app
```
```bash
pnpm create next-app --example script-component script-component-app
```
Deploy it to the cloud with [Vercel](https://vercel.com/new?utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).