Commit graph

1797 commits

Author SHA1 Message Date
Steven
b684b110e4
Add props objectFit and objectPosition to Image component (#18849)
Fixes #18794
2020-11-05 19:42:55 +00:00
Matthew Lilley
8e9e9494dd
Fix issues with apollo cache data merging and restoration (#17681)
This PR fixes issues in two apollo examples where cached queries are lost, and cached data is merged incorrectly.
2020-11-05 18:24:39 +00:00
Vitor Dino
6ea504a6a0
feat(examples): use next-plugin-preact on using-preact example (#18588)
hey there 👋 

stumbled on the [`using-preact` example](https://github.com/vercel/next.js/tree/canary/examples/using-preact) first when i tried to port my project, just saw that the [config wasn’t that trivial](https://github.com/vercel/next.js/issues/13969#issuecomment-641540051), and it would fit better on a [plugin](https://github.com/preactjs/next-plugin-preact)..

I did this migration first on my project (it worked super well) and realized that people also would dislike having to maintain that kind of code, and would stumble faster on the plugin if it was already on the official example 
2020-11-05 16:56:58 +00:00
Steven
35f8f521a2
Update Image docs with links to examples (#18770)
This revises the docs to add headings and also links to layout examples.

Fixes #18554
2020-11-04 17:24:14 +00:00
Matsumoto Toshi
5ecdcab648
fix: Using getIdToken to get a token (#18599)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-11-03 20:40:42 -05:00
Steven
d4a92d92ba
Update example for Image Component (#18762) 2020-11-03 15:40:53 -05:00
Aral Roca Gomez
44ea598f88
Update next-translate example to support Next 10 with i18n routing (#18480)
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-11-03 09:48:26 -05:00
Carmelo Scandaliato
197d46ddb9
Remove the static optimization indicator (#18629)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-11-02 09:27:36 +01:00
Daniel Treviño
a6660729ea
fix: issue #18360 - loading spinner not showing up (#18527)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-30 13:48:55 -05:00
ospira
3bbb35c323
small tweaks for those testing on an existing site with missing autho… (#18506)
* small tweaks for those testing on an existing site with missing author or featured image on posts

When migrating WordPress or using an exisitng site, sometimes you have published posts wth missing data. The graphql plugin will properly resolve these to null, but some of existing code accessing tries to access the node property on these null values. I've made these properties optional in the pages and also tweaked some of the components along similar lines.

* Lint fix

Co-authored-by: Luis Alvarez <luis@vercel.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-30 13:45:18 -05:00
Yudai Oriver K
61981da9e0
Fix i18n-routing Vercel deploy button URLs (#18524)
Fixes #18523

## description
The i18n-routing Vercel deploy button URLs was:
https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/amp

So, I fixed the URLs for examples/i18n-routing:
https://vercel.com/import/project?template=https://github.com/vercel/next.js/tree/canary/examples/i18n-routing
2020-10-30 15:44:21 +00:00
Yuji Matsumoto
629884af7d
Update using-preact example's dependencies (#18493)
- Update Next.js version to 10.0.0
- Update the other dependencies
- Modify `next.config.js` to prevent circular `__self` and `__source`in dev env (ref: https://github.com/developit/nextjs-preact-demo/issues/25)
2020-10-29 22:52:27 +00:00
Joris W
7d4b36cccd
Fix GSP page titles in i18n-routing example (#18465) 2020-10-29 12:48:12 +01:00
Jip Sterk
e058fa49d0
remove unneeded deps & updated example (#17651)
Closes #17626
2020-10-29 02:31:17 +00:00
Sebastian Troć
4caf98efbf
Tweak Image Optimization URL in example (#18355) 2020-10-28 13:04:09 +00:00
Quinn Turner
6d4395f22c
fix: Order moduleFileExtensions left-to-right (#18328)
Order moduleFileExtensions from most used to least used extensions.

Sources: https://jestjs.io/docs/en/configuration#modulefileextensions-arraystring
and facebook/jest#7616
2020-10-27 20:20:03 +00:00
JJ Kasper
1b22a39eb1
Add initial example for i18n routing (#18206)
This is a follow-up to https://github.com/vercel/next.js/pull/18067 adding an example for i18n routing

x-ref: https://github.com/vercel/next.js/pull/17370
2020-10-27 07:59:44 +00:00
Steven
3c6f421d99
Add docs for Image Optimization (#18107)
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2020-10-24 14:53:28 +02:00
Tuan Nguyen
c28d39e47d
Use ya in case xa is false (#18074)
This closes [#18023](https://github.com/vercel/next.js/issues/18023). 

I was following the example mentioned in the issue (https://github.com/vercel/next.js/tree/canary/examples/with-firebase-authentication) and for some reason `xa` was always false, failing fetching food. Through `console.log` I saw that `ya` contained a token value and using `ya` worked.
2020-10-21 01:17:39 +00:00
Justin W Hall
c9d4d6299e
Update step 5 to Strapi example Readme (#17985)
Co-authored-by: Rémi de Juvigny <remi@hey.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-19 11:32:01 +02:00
Ash Connell
fd4eb558a2
Add with-facebook-pixel example (#17667) 2020-10-19 00:00:27 +00:00
Or Yoffe
68c62b3307
Updated dependencies for example: with-react-native-web (#17375)
The current dependencies of  the example "with-react-native-web" are outdated.
In this PR I updated them and tested that they run and work.

Newest current react and react-dom versions: 16.13.1
Newest current  react-native-web and babel-plugin-react-native-web versions: 0.13.14

Mainly for the people starting with this example to have the new versions since the current versions are very far from each other.
Please merge 🙏
2020-10-18 17:56:41 +00:00
Ash Connell
82041542e3
Fix with-mongodb hot-reload issue and race condition (#17666)
This PR fixes 2 issues with the mongodb example:

### 1. Fallable Caching Strategy

Calling `connectToDatabase()` multiple times before it's cached results in multiple connections being created. The latest one created was becoming the "cached" one and the others dissappear into the background.

This is now fixed by using **promise sharing** so that only one connection can ever be created.

### 2. Problematic Hot Reload

During development you can monitor your database connections and see that it continues to create more and more connections over time. Some users have reported their [databases reaching maximum connection limits](https://github.com/vercel/next.js/discussions/12229).

This is resolved by using `global` to store the cached connection. It's not ideal but it is necessary.
2020-10-17 00:30:38 +00:00
kamei
ee0a4a7086
Fixed link for expo (#17908) 2020-10-15 15:11:35 +02:00
Davidson Nascimento
d396bc68fb
feat(example): added missing prisma.io examples (#17896) 2020-10-15 15:10:24 +02:00
Henrik Wenz
1c4aecbeaf
Improve with-tailwindcss example (#17742)
## Change

To opt-in to using the new layers mode by default.

## Motivation

- Reduces CSS filesize
- Prevents users from using the already deprecated old layers mode
- Removes the following console warnings:

```log
risk - There are upcoming breaking changes: purgeLayersByDefault
risk - We highly recommend opting-in to these changes now to simplify upgrading Tailwind in the future.
risk - https://tailwindcss.com/docs/upcoming-changes
```

[more info](https://tailwindcss.com/docs/upcoming-changes)
2020-10-12 16:37:56 +00:00
Jens Meindertsma
c021662d1e
Fix with-msw example (#17695)
When using the `with-msw` example I noticed it increased my bundle size in production, even through MSW is meant to be used in development only. 

**Build size before implementing MSW**
```
Page                                                           Size     First Load JS
┌ λ /                                                          479 B          58.9 kB
├   /_app                                                      0 B            58.4 kB
└ ○ /404                                                       3.44 kB        61.9 kB
+ First Load JS shared by all                                  58.4 kB
  ├ chunks/f6078781a05fe1bcb0902d23dbbb2662c8d200b3.b1b405.js  10.3 kB
  ├ chunks/framework.cb05d5.js                                 39.9 kB
  ├ chunks/main.a140d5.js                                      7.28 kB
  ├ chunks/pages/_app.b90a57.js                                277 B
  └ chunks/webpack.e06743.js                                   751 B

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
   (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
```
**Build size after implementing MSW according to the `with-msw` example**
```
Page                                                           Size     First Load JS
┌ λ /                                                          479 B          71.6 kB
├   /_app                                                      0 B            71.1 kB
└ ○ /404                                                       3.44 kB        74.6 kB
+ First Load JS shared by all                                  71.1 kB
  ├ chunks/f6078781a05fe1bcb0902d23dbbb2662c8d200b3.b1b405.js  10.3 kB
  ├ chunks/framework.cb05d5.js                                 39.9 kB
  ├ chunks/main.a140d5.js                                      7.28 kB
  ├ chunks/pages/_app.c58a6f.js                                13 kB
  └ chunks/webpack.e06743.js                                   751 B

λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
○  (Static)  automatically rendered as static HTML (uses no initial props)
●  (SSG)     automatically generated as static HTML + JSON (uses getStaticProps)
   (ISR)     incremental static regeneration (uses revalidate in getStaticProps)
```

There was a 12.7 kB large increase in the `_app` First Load JS which increased the pages' First Load JS size. I tracked the problem down to the following code: 
```js
if (process.env.NEXT_PUBLIC_API_MOCKING === 'enabled') {
  require('../mocks')
}
```
Removing this reduces the `_app` First Load JS to what it was previously. The `NEXT_PUBLIC_API_MOCKING` environment variable is defined in the `.env.development` file, as this means that Next.js will only activate MSW during development/testing, which is what MSW is intended for.

After discussing with @kettanaito, the author of MSW, I did some investigation. This dynamic require statement is intended to allow tree-shaking of the MSW package for production. Unfortunately this did not seem to be working. To fix this, I changed the code to the following:
```js
if (process.env.NODE_ENV !== 'production') {
  require('../mocks')
}
```
This means I could remove the `NEXT_PUBLIC_API_MOCKING` environment variable  from `.env.development`, as it is no longer used. 

It is important to note that this still achieves the same functionality as before: MSW runs in development / testing, and not in production. If MSW must be enabled in production for some reason, the following code can be used to run MSW regardless of the environment:
```js
if (true) {
  require('../mocks')
}
```

If possible, I'd love to hear from the Next.js maintainers regarding the tree-shaking process when using environment variables.

Lastly, I made the necessary changes to have the example work in production mode as well, because there is no real backend. Of course there is a comment explaining what should be changed in a real world app.
2020-10-08 18:19:29 +00:00
Henrik Wenz
a79bcfb73a
Fix with-apollo example (#17686)
# Issue

The cache updates are performed in a wrong way, resulting in a duplicate collection:

**Error:**

```log
webpack-internal:///./node_modules/react-dom/cjs/react-dom.development.js:88 Warning: Encountered two children with the same key, `6f3f7265-0d97-4708-a3ea-7dee76dc0a0a`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
```

**Video:**

![broken](https://user-images.githubusercontent.com/1265681/95336501-0c170180-08b1-11eb-9273-6ac9e37ceb41.gif)

# Fix

**Video:**

![fixed](https://user-images.githubusercontent.com/1265681/95336538-15a06980-08b1-11eb-8d5e-6acc07e16138.gif)
2020-10-08 03:45:28 +00:00
Tantan Fu
4c38e3ed8e
fix typo (#17653) 2020-10-06 15:31:40 +00:00
Rafael Zerbini
d32b195539
Fixes #16431 (#17610)
Fixes #16431
* Added `.babelrc` with `next/babel` to remove the need of the React import on the `with-storybook` example.
2020-10-05 06:27:43 +00:00
Riccardo Di Maio
10f7b8f941
Improve formatting in examples (#17571) 2020-10-02 21:25:29 +00:00
Dylan Jhaveri
2a047a8f17
update README for vercel.app, stream.new (#17539) 2020-10-01 22:46:17 -04:00
Philihp Busby
f06c589115
with-google-analytics-amp needs <Head /> in Document component (#17462)
If this component is missing, an error will be printed to the console

```
Expected Document Component Head was not rendered. Make sure you render them in your custom `_document`
See more info here https://err.sh/next.js/missing-document-component
```

Additionally, any components which use CSS modules will fail with an error.

This is documented in https://nextjs.org/docs/advanced-features/custom-document
2020-09-30 08:41:05 +00:00
Amandeep Singh
02d7504670
Fixed minor typo (#17456) 2020-09-29 19:31:43 +00:00
Tim Feeley
b009ebbec6
Fix a small typo in index.css (#17399) 2020-09-27 22:17:03 +00:00
Rishi Raj Jain
92fc260e4c
Update README.md (#17347)
As clear from [#14233](https://github.com/vercel/next.js/pull/14233#issuecomment-645997757) that the 'with-algolia example is not SSR', I've updated the documentation to clear the confusion caused, as visible in #17229 

Fixes #17229
2020-09-25 01:55:11 +00:00
Antonio Pitasi
c388048f3e
fix(examples/with-redux-wrapper): wrong initial state (close #17299) (#17335)
Wrong variable was being checked for the hydrate action on redux. This was causing the count to be reset to 0 instead of being 1 when initially loading index.js page.

Fixes #17299
2020-09-24 19:35:46 +00:00
Sébastien Vanvelthem
f3eadac467
Example: with-next-auth updated to v3 (#17266)
Update [`next-auth`](https://github.com/iaincollins/next-auth) from `^2.1.0` to `^3.1.0` and minor sqlite bump to `^5.0.0`.
2020-09-21 19:51:52 +00:00
Kazuma Furuhashi
31ab12aaf7
Add project name to examples/with-three-js create command (#17256)
This is a change to add the project name as in the other examples.
When we run with the current create command, we are asked for the project name.
As follows:

```
$ npx create-next-app --example with-three-js
? What is your project named? › my-app
```
2020-09-21 17:02:25 +00:00
paulogdm
3400052cbb
Delete vercel.json from "yarn workspaces" example (#17263)
This PR removes "vercel.json" from the Yarn workspaces example. Since the release of [monorepos](https://vercel.com/blog/monorepos) support, there is no need to use the "builds" property or "vercel.json".
2020-09-21 16:39:51 +00:00
tomasdisk
3dee6097cd
Add with-chakra-ui-typescript example (#16561)
This PR adds an example Next.js project with chakra-ui as its component library using TypeScript.
![image](https://user-images.githubusercontent.com/11686408/91192736-a8ec5980-e6cc-11ea-8f95-b9180defbf47.png)
Both libraries has built-in TypeScript declarations. Will help to encourage typed projects, so why not?

It's a combination of two existing examples [with-chakra-ui](https://github.com/vercel/next.js/tree/canary/examples/with-chakra-ui) and [with-typescript](https://github.com/vercel/next.js/tree/canary/examples/with-typescript).

All credits for their contributors.
2020-09-21 04:54:15 +00:00
Nghiệp
111d2df90c
[Examples] Optimize with-docker (#17116)
* Fix missing yarn.lock
* Add --frozen-lockfile flag to speed up install deps
* Make sure node_modules do not contains devDependencies
* Add --targe stage docker build
2020-09-21 04:09:37 +00:00
Ilya Lebedev
db82f9ce6d
[Example] with-react-intl: fix doubling messages (#17175)
Because `import()` for .json files return object like this:

```json
{
  "default": {
     "some": ...
  },
 "some": ...
}
```

![image](https://user-images.githubusercontent.com/2598671/93468826-4156b200-f8f8-11ea-8e39-42df2df83057.png)
2020-09-21 03:47:58 +00:00
Ilya Lebedev
231016f69f
[Example] with-react-intl: fix getInitialProps props ordering (#17174)
Invalid ordering in Promise.all and in receiving destruction.

Now appProps receives result of polyfill(supportedLocale) call.
2020-09-21 03:26:47 +00:00
Devin Ekadeni
4f1ccda5bd
[Example] With TS Eslint Jest - unnecessary package (#17170)
As mentioned in [here](https://www.npmjs.com/package/@types/testing-library__react), the package has been deprecated and not necessary to be installed.
By removing this from `package.json` will give other devs have more understanding when learning typescript with eslint and jest about what need to be installed on the project.
2020-09-21 03:06:21 +00:00
Austin Huang
2e87e22731
Fix for missing babel dependencies in with-rebass example (#16839)
Pull request for (Issue: Fix or remove the with-rebass example #16828). Just added some missing dependencies to the package.json of the example

Fixes #16839
2020-09-21 02:16:15 +00:00
Mohamed Akram
eaea7a8793
Update PatternFly example to v4 (#17241)
`esModule: false` required for fonts to load.
2020-09-20 22:00:41 +00:00
Long Ho
67b67b28b2
feat(examples/with-react-intl): add locale negotation to client side (#16806)
fix #16752

cc @thuringia
2020-09-16 23:01:21 +00:00
Jens Meindertsma
a3c47721a1
Include all files in Prettier (#17050)
This uses the "Expand directories" feature introduces in Prettier 2.0 to automatically format all supported file types.

Also, I fixed some badly formatted files.
2020-09-14 02:53:19 +00:00
Fran Zekan
0f41062db0
Examples blogs: fix spelling (#17049)
Throughout some of the blog examples word `formatter` is spelled as `formater`, this PR changes all of them to `formatter`
2020-09-13 13:06:29 +00:00