This is a boilerplate for these technologies:
- TypeScript
- Next.js
- Styled Components
- GraphQL
- SSR
- Check this repo out.
yarn install
yarn dev
- open http://localhost:3000/
Happy coding :)
This is a boilerplate for these technologies:
yarn install
yarn dev
Happy coding :)
Getting the warning "You have opted-out of Automatic Static Optimization due to getInitialProps in pages/_app." However there isn't any getInitialProps in our custom _app.js
import React from "react"
import App from "next/app"
import Head from "next/head"
import { ThemeProvider, createGlobalStyle } from "styled-components"
import { ApolloProvider } from "@apollo/react-hooks"
import withApollo from "../hooks/withApollo"
import { ApolloClient, NormalizedCacheObject } from "apollo-boost"
export interface ITheme {
niceBlack: string;
}
export interface IThemeWrapper {
theme: ITheme;
}
export const theme: ITheme = {
niceBlack: "#001F3F",
}
const GlobalStyle = createGlobalStyle<IThemeWrapper>`
body {
margin: 0 auto;
color: ${props => props.theme.niceBlack};
}
`
// since "apollo" isn't a native Next.js prop we have to declare it's type.
interface IProps {
apollo: ApolloClient<NormalizedCacheObject>;
}
// adds our custom props interface to the generic App base class.
class MyApp extends App<IProps> {
render() {
// instead of creating a client here, we use the rehydrated apollo client provided by our own withApollo provider.
const { Component, pageProps, apollo } = this.props
return (
<React.Fragment>
<Head>
<title>GraphQL Job Board</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
{/* adds the apollo provider to provide it's children with the apollo scope. */}
<ApolloProvider client={apollo}>
<ThemeProvider theme={theme}>
<GlobalStyle />
<Component {...pageProps} />
</ThemeProvider>
</ApolloProvider>
</React.Fragment>
)
}
}
// before exporting our App we wrapp it with our own withApollo provider to have access to the our rehydrated apollo client.
export default withApollo(MyApp)
No warnings when running yarn build
Thanks a lot for your tutorial, it helps me a lot!
I'm trying to accomplish the same for my blog. Works well but it's not SSR. Do you know where I'm wrong?
I would be interested in seeing a pure javascript version of this, but I know that's a big ask. However, I'm curious about what the javascript alternative would be for this line:
<JobList jobs={jobs?.data?.jobs || []} />
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.