Unverified Commit 588a61b4 authored by Henrik Wenz's avatar Henrik Wenz Committed by GitHub

[Docs] Migrate using-preact example to typescript (#40295)

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
parent 34fa5f85
const withPreact = require('next-plugin-preact') const withPreact = require('next-plugin-preact')
module.exports = withPreact({ /** @type {import('next').NextConfig} */
const nextConfig = {
/* regular next.js config options here */ /* regular next.js config options here */
}) }
module.exports = withPreact(nextConfig)
...@@ -5,14 +5,18 @@ ...@@ -5,14 +5,18 @@
"build": "next build", "build": "next build",
"start": "next start" "start": "next start"
}, },
"devDependencies": {},
"dependencies": { "dependencies": {
"next": "^12.0.0", "next": "latest",
"next-plugin-preact": "^3.0.6", "next-plugin-preact": "latest",
"preact": "^10.5.15", "preact": "^10.10.6",
"preact-render-to-string": "^5.1.19", "preact-render-to-string": "^5.2.3",
"react": "npm:@preact/compat@^17.0.2", "react": "npm:@preact/compat@^17.1.1",
"react-dom": "npm:@preact/compat@^17.0.2", "react-dom": "npm:@preact/compat@^17.1.1",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.2.0" "react-ssr-prepass": "npm:preact-ssr-prepass@1.2.0"
},
"devDependencies": {
"@types/node": "18.7.15",
"@types/react": "16.9.17",
"typescript": "4.8.2"
} }
} }
export default function About() { export default function AboutPage() {
return <div>About us</div> return <div>About us</div>
} }
import Link from 'next/link' import Link from 'next/link'
export default function Home() { export default function IndexPage() {
return ( return (
<div> <div>
Hello World.{' '} Hello World.{' '}
......
export default function SSG({ framework }) { import { InferGetStaticPropsType } from 'next'
return <div>{framework} ssg example</div>
}
export function getStaticProps() { export function getStaticProps() {
return { return {
props: { framework: 'preact' }, props: { framework: 'preact' },
} }
} }
export default function SSGPage({
framework,
}: InferGetStaticPropsType<typeof getStaticProps>) {
return <div>{framework} ssg example</div>
}
export default function SSR({ framework }) { import { InferGetServerSidePropsType } from 'next'
return <div>{framework} ssr example</div>
}
export function getServerSideProps() { export function getServerSideProps() {
return { return {
props: { framework: 'preact' }, props: { framework: 'preact' },
} }
} }
export default function SSRPage({
framework,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
return <div>{framework} ssr example</div>
}
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"moduleResolution": "node",
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment