Commit graph

69 commits

Author SHA1 Message Date
Arunoda Susiripala
01a17738db Reset prefetchCache when reloading a route. (#617)
* Reset prefetchCache when reloading a route.

* Prefetch again when there's a HMR reload.

* Make .send() to return a promise.
2017-01-02 20:18:14 +09:00
Naoyuki Kanezawa
c1a620a7c4 Support relative urls on Link component (#614)
* link: support relative urls

* link: support protocol-relative urls

* router: fix error for clicking anchor tag
2017-01-01 22:22:07 -08:00
Naoyuki Kanezawa
897c60b4fd Fix error routes (#595)
* fix router error handlings

* respond with JSON when error occurs on JSON routes
2017-01-01 11:36:37 -08:00
Arunoda Susiripala
c890dc3573 Implement Router Events (#511)
* Move route loading logic to a common place.

* Add router events.

* Add EventEmitter's core API methods.

* Add example app for loading events and docs.

* Fix some typos.

* Get rid of Router.ready()

* Remove events package.
It's already shipping with webpack.

* Handling aborting properly.

* Expose simple attribute based events listener API.
Removed the proposed event listener API from the public API.

* Remove error logged when there's an abort error.
There are many other ways to capture this error.
So, it doesn't look nice to print this always.

* Change router events to pass only the current URL as arguments.

* Add a section about Cancelled Routes to README.
2016-12-30 17:15:22 -08:00
Naoyuki Kanezawa
0f11018819 fix getInitialProps called on client on first load (#572) 2016-12-30 11:55:00 -08:00
Tim Neutkens
e8985b3588 Add warning for multiple children in Link (#558)
* Add warning for multiple children in Link

* Add space after if

* Use proptype validation
2016-12-29 21:53:20 +09:00
Naoyuki Kanezawa
242758e3ee fix navigation failure (#546) 2016-12-27 21:27:52 -08:00
Naoyuki Kanezawa
af2d78c042 router: register initial route (#508) 2016-12-24 09:29:23 -08:00
Dan Zajdband
01e1883f79 Added glamor example and pointing warning to css migration guide (#500) 2016-12-23 11:18:25 -08:00
Naoyuki Kanezawa
74d4d22f84 router: fix route value on popstate (#490) 2016-12-23 09:14:14 -08:00
nkzawa
6b18e34f66 link: tweak scroll condition 2016-12-22 17:17:50 +09:00
James O'Dwyer
31feced24a Avoid autoscrolling anchored URLs (#474)
* force scroll to false if # is found in url

* only overwrite scroll if scroll=true is not passed in

* clean up logic around setting scroll var
2016-12-22 17:15:49 +09:00
Naoyuki Kanezawa
2a29bf6242 display deprecation warning only when method was called (#462) 2016-12-21 10:43:31 -08:00
Arunoda Susiripala
141c045c68 Make next/router a client only API. (#443)
* Prevent using 'next/router' APIs inside 'getInitialProps'

* Remove incorrect documentation.

* Make next/router a client only API.
2016-12-20 09:27:43 -08:00
Arunoda Susiripala
565bb5790b Update url.pushTo and url.replaceTo update only on dev. (#434)
In order to warn the user, now we are using a warn function
which is located in the lib/utils module.
2016-12-19 13:04:38 -08:00
Arunoda Susiripala
e45cc89ce3 Add deprecate messages for url.replaceTo and url.pushTo (#433) 2016-12-19 10:49:15 -08:00
Arunoda Susiripala
22776c2eee Implement the Singleton Router API (#429)
* Immplement the initial singleton Router.

* Use the new SingletonRouter for HMR error handling.

* Use SingletonRouter inside the Link.

* Create an example app using the Router.

* Make the url parameter optional in Router.push and Router.replace

* Add a section about next/router in the README.
2016-12-19 06:40:26 -08:00
Naoyuki Kanezawa
1e70324a41 print a deprecated message for next/css (#421) 2016-12-17 13:59:38 -08:00
Arunoda Susiripala
37a9c661ff Make prefetching works again. (#422) 2016-12-17 13:59:03 -08:00
Thomas Jaggi
de6521a481 Allow for custom route in pushTo and replaceTo methods (#417) 2016-12-18 05:18:50 +09:00
Arunoda Susiripala
b62a0e8f55 Bundle all the modules inside the app (#414)
* Remove the use of CDN and bundle everything inside the app.
We still pre-build the prefetcher because it needs
different webpack config which only targets browsers
supports Service Workers.

* Remove cdn config item.
We no longer using it.

* Stop adding script tags when staticMarkup=true

* Remove babel-plugin-transform-remove-strict-mode NPM module.
2016-12-17 17:49:10 +09:00
Naoyuki Kanezawa
1708222381 Programmatic API (#310)
* add 'next' api

* add render APIs

* add 'as' prop to Link

* check Accept header to serve json response

* check if response was finished on getInitialProps call

* move server/app to server/index

* load webpack-hot-middleware-client by absolute path

* server: options for testing

* add tests

* example: improve

* server: make dir optional

* fix client routing

* add parameterized routing example

* link: fix display url

* Add custom-server-express example (#352)

* Add custom-server-express example

* Remove extraneous nexts in express routes defs

* Update next config in server.js

* Handle accept headers totally inside Next.js (#385)

* Handle accept headers totally inside Next.js
Now user doesn't need to handle it anymore.

* Move json pages serving to /_next/pages base path.

* Join paths correctly.

* remove next/render
2016-12-16 12:33:08 -08:00
Naoyuki Kanezawa
8ddafaea5c custom document support (#405) 2016-12-16 10:42:40 -08:00
Arunoda Susiripala
43b0e6f514 Remove console.logs (#402) 2016-12-16 11:43:46 +09:00
Arunoda Susiripala
36abdc77c5 Prefetch pages with Service Workers (#375)
* Register the service worker.

* Update prefetcher code to do prefetching.

* Implement the core prefetching API.
support "import <Link>, { prefetch } from 'next/prefetch'"

* Implement a better communication system with the service worker.

* Add a separate example for prefetching

* Fix some typos.

* Initiate service worker support even prefetching is not used.
This is pretty important since initiating will reset the cache.
If we don't do this, it's possible to have old cached resources
after the user decided to remove all of the prefetching logic.
In this case, even the page didn't prefetch it'll use the
previously cached pages. That because of there might be a already running
service worker.

* Use url module to get pathname.

* Move prefetcher code to the client from pages
Now we also do a webpack build for the prefetcher code.

* Add prefetching docs to the README.md

* Fix some typo.

* Register service worker only if asked to prefetch
We also clean the cache always, even we initialize
the service worker or not.
2016-12-15 11:13:40 -08:00
Matthew Mueller
a8f58be450 fix link for environments without synthetic events (like preact/the browser) (#393) 2016-12-15 10:03:02 +05:30
Luke Edwards
249a0c4007 append bundle script to body (#353) 2016-12-07 08:53:50 +09:00
nkzawa
0b20273c77 remove workaround for react-hot-loader 2016-12-04 07:06:47 +09:00
Naoyuki Kanezawa
f049a0bfa0 fix reading incorrect package.json (#323) 2016-12-02 15:56:02 +09:00
nkzawa
6ad1e23167 Merge branch 'master' into pr/259 2016-12-02 10:35:07 +09:00
Arunoda Susiripala
fcd59adea1 Add support for webpack's CommonsChunkPlugin and remove next bundle (#301)
* Add example app which demonstrate the problem.

* Add the first working version.

* Fix lint issues.

* Add README.md

* Use /_next/main.js as the main file URI

* Add the support for loading the core next bundle.

* Optimize the output by removing Next modules from pages.

* Use the same package.json as master use.

* Change the example repo's README for simpler instructions.

* Change example projects package.json to support next build and start.

* Change main.js into commons.js.

* Add support for hot core reload and errors.

* Introduce require based on eval-script.

* Add error reporting support with hot reloading.

* Update README.md
2016-11-28 09:15:56 +09:00
Naoyuki Kanezawa
c7ba914f52 Handle runtime errors (#268)
* display runtime errors by error-debug

* server: fix status

* render Error component on client error

* server: render runtime errors of error template

* server: handle errors of error template on render404

* server: add a comment

* server: refactor renderJSON

* recover from runtime errors

* _error: check if xhr exists

* _error: improve client error

* _error: improve error message
2016-11-24 23:03:16 +09:00
Benjamin Coe
c56fde89c3
chore: add test coverage 2016-11-22 10:11:23 -08:00
zpnk
e0455823a0 Add default utf-8 charset. (#270) 2016-11-17 15:06:54 -08:00
nkzawa
5383ad7ed9 fix getInitialProps doesn't get called when only url query was changed 2016-11-06 17:34:51 +09:00
nkzawa
efbf0efc98 fix query for getInitialProps is not parsed as an object 2016-11-06 15:09:37 +09:00
Naoyuki Kanezawa
d1a0309af9 Add pathname and query to the argument of getInitialProps (#194)
* pass pathname and query to getInitialProps on both server and client

* README: describe about the contet object of getInitialProps
2016-11-04 01:05:03 -07:00
David Street
7186fe8b7e Only update history state if url differs. (#172) 2016-11-03 19:15:03 +09:00
Naoyuki Kanezawa
037e2d9c26 batch update head contents (#129)
* head-manager: batch update

* side-effect: remove redundant rendering cycle checks
2016-10-28 23:39:20 +09:00
Naoyuki Kanezawa
93d856706b add cdn config (#111) 2016-10-28 23:38:24 +09:00
Naoyuki Kanezawa
1952a47a90 Merge pull request #39 from zeit/add/css-default-export
Exposing glamor style as default
2016-10-25 15:57:44 +09:00
Naoyuki Kanezawa
ebecbcf89e Load client js from cdn with fallback (#34)
* load client js from cdn with fallback

* fix cdn url
2016-10-25 01:50:33 -04:00
nkzawa
7569ef6ca9 hot reload compilation errors 2016-10-25 00:20:50 +09:00
nkzawa
7ec46d512b hot reload added/removed pages 2016-10-24 16:22:15 +09:00
Dan Zajdband
6743e2b014 Exposing glamor style as default allowing different ways to import the css helpers 2016-10-22 09:45:41 +02:00
Dan Zajdband
e164074f8e Added glamor css (#38)
* Added glamor css

* Using pseudoclasses instead of calling functions

* Updated readme using style instead of default import for css
2016-10-21 09:39:20 -07:00
nkzawa
2e2db37ccb add error page for debug 2016-10-19 21:41:45 +09:00
nkzawa
3c44137b9b improve hot-reloading 2016-10-17 23:35:31 +09:00
nkzawa
60aa5869e4 document: refactoring 2016-10-17 17:08:53 +09:00
nkzawa
1be8447a26 Merge branch 'master' into add/hot-reload 2016-10-17 11:10:16 +09:00