summaryrefslogtreecommitdiff
path: root/history/docs/Misc.md
diff options
context:
space:
mode:
Diffstat (limited to 'history/docs/Misc.md')
-rw-r--r--history/docs/Misc.md51
1 files changed, 51 insertions, 0 deletions
diff --git a/history/docs/Misc.md b/history/docs/Misc.md
new file mode 100644
index 0000000..cff65e4
--- /dev/null
+++ b/history/docs/Misc.md
@@ -0,0 +1,51 @@
+## Using a Base URL
+
+If all the URLs in your app are relative to some other "base" URL, use the `basename` option. This option transparently adds the given string to the front of all URLs you use.
+
+```js
+const history = createHistory({
+ basename: '/the/base'
+});
+
+history.listen(location => {
+ console.log(location.pathname); // /home
+});
+
+history.push('/home'); // URL is now /the/base/home
+```
+
+**Note:** `basename` is not supported in `createMemoryHistory`.
+
+## Forcing Full Page Refreshes in createBrowserHistory
+
+By default `createBrowserHistory` uses HTML5 `pushState` and `replaceState` to prevent reloading the entire page from the server while navigating around. If instead you would like to reload as the URL changes, use the `forceRefresh` option.
+
+```js
+const history = createBrowserHistory({
+ forceRefresh: true
+});
+```
+
+## Modifying the Hash Type in createHashHistory
+
+By default `createHashHistory` uses a leading slash in hash-based URLs. You can use the `hashType` option to use a different hash formatting.
+
+```js
+const history = createHashHistory({
+ hashType: 'slash' // the default
+});
+
+history.push('/home'); // window.location.hash is #/home
+
+const history = createHashHistory({
+ hashType: 'noslash' // Omit the leading slash
+});
+
+history.push('/home'); // window.location.hash is #home
+
+const history = createHashHistory({
+ hashType: 'hashbang' // Google's legacy AJAX URL format
+});
+
+history.push('/home'); // window.location.hash is #!/home
+```